Skip to content

Commit

Permalink
Hamster wheel functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Sydokiddo committed Oct 30, 2024
1 parent c7b07c6 commit 2cf7ba8
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 199 deletions.
342 changes: 190 additions & 152 deletions src/main/java/com/starfish_studios/hamsters/entity/HamsterNew.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.Goal;

import java.util.EnumSet;

public class SleepGoal<E extends PathfinderMob & SleepingAnimal> extends Goal {

public final E mob;

public SleepGoal(E mob) {
Expand All @@ -16,29 +16,26 @@ public SleepGoal(E mob) {
@Override
public void start() {
// After the goal is activated, makes the mob stop jumping, start sleeping, and stop moving.
mob.setJumping(false);
mob.setSleeping(true);
mob.getNavigation().stop();
mob.getMoveControl().setWantedPosition(mob.getX(), mob.getY(), mob.getZ(), 0.0D);
this.mob.setJumping(false);
this.mob.setSleeping(true);
this.mob.getNavigation().stop();
this.mob.getMoveControl().setWantedPosition(this.mob.getX(), this.mob.getY(), this.mob.getZ(), 0.0D);
}

@Override
public boolean canUse() {
// If the mob is not moving and can sleep or is already sleeping, return true
if (mob.xxa == 0.0F && mob.yya == 0.0F && mob.zza == 0.0F) {
return mob.canSleep() || mob.isSleeping();
} else {
return false;
}
if (this.mob.xxa == 0.0F && this.mob.yya == 0.0F && this.mob.zza == 0.0F) return this.mob.canSleep() || this.mob.isSleeping();
else return false;
}

@Override
public boolean canContinueToUse() {
return mob.canSleep();
} // Allows the mob to continue sleeping if it can sleep (i.e., if it is not interrupted)
return this.mob.canSleep(); // Allows the mob to continue sleeping if it can sleep (i.e., if it is not interrupted)
}

@Override
public void stop() {
mob.setSleeping(false);
} // Wakes up the mob when the goal ends
}
this.mob.setSleeping(false); // Wakes up the mob when the goal ends
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
@SuppressWarnings("unused")
public class HamstersTags {

public static final TagKey<EntityType<?>> HAMSTER_PREDATORS = TagKey.create(Registries.ENTITY_TYPE, Hamsters.id("hamster_predators"));
public static final TagKey<Block> HAMSTER_BLOCKS = TagKey.create(Registries.BLOCK, Hamsters.id("hamster_blocks"));
public static final TagKey<Block> HAMSTER_WHEELS = TagKey.create(Registries.BLOCK, Hamsters.id("hamster_wheels"));

public static final TagKey<Block> HAMSTERS_SPAWNABLE_ON = TagKey.create(Registries.BLOCK, Hamsters.id("hamsters_spawnable_on"));

public static final TagKey<Item> CAGE_PANELS = TagKey.create(Registries.ITEM, Hamsters.id("cage_panels"));
public static final TagKey<Item> HAMSTER_FOOD = TagKey.create(Registries.ITEM, Hamsters.id("hamster_food"));

public static final TagKey<Block> HAMSTER_BLOCKS = TagKey.create(Registries.BLOCK, Hamsters.id("hamster_blocks"));
public static final TagKey<Block> HAMSTER_WHEELS = TagKey.create(Registries.BLOCK, Hamsters.id("hamster_wheels"));
public static final TagKey<EntityType<?>> HAMSTER_AVOIDED = TagKey.create(Registries.ENTITY_TYPE, Hamsters.id("hamster_avoided"));

public static final TagKey<Biome> HAS_HAMSTER = TagKey.create(Registries.BIOME, Hamsters.id("has_hamster"));
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"values": [
"minecraft:player",
"minecraft:wolf",
"minecraft:cat",
"minecraft:ocelot",
"minecraft:fox"
]
}

This file was deleted.

0 comments on commit 2cf7ba8

Please sign in to comment.