[change] change some settings for Pinguin/Rooster/Firefly
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
package ovh.glitchlabs.masterwild.entity.custom;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.AgeableMob;
|
||||
@@ -18,36 +16,31 @@ import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ovh.glitchlabs.masterwild.Sounds.ModSounds;
|
||||
import ovh.glitchlabs.masterwild.entity.ModEntities;
|
||||
|
||||
public class RoosterEntity extends Animal {
|
||||
|
||||
boolean newDay = false;
|
||||
private long lastDay;
|
||||
// -1 = noch kein Tag erfasst -> beim Laden/Betreten der Welt wird nicht gekräht
|
||||
private long lastDay = -1;
|
||||
private int crowDelay = -1;
|
||||
|
||||
public RoosterEntity(EntityType<? extends Animal> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
xpReward = 10;
|
||||
setNoAi(false);
|
||||
this.setPathfindingMalus(PathType.WATER, 0.0F);
|
||||
}
|
||||
|
||||
public static AttributeSupplier.Builder createAttributes() {
|
||||
AttributeSupplier.Builder builder = Mob.createMobAttributes();
|
||||
builder = builder.add(Attributes.MOVEMENT_SPEED, 0.3);
|
||||
builder = builder.add(Attributes.MAX_HEALTH, 5);
|
||||
builder = builder.add(Attributes.ARMOR, 0);
|
||||
builder = builder.add(Attributes.ATTACK_DAMAGE, 0);
|
||||
builder = builder.add(Attributes.FOLLOW_RANGE, 16);
|
||||
builder = builder.add(Attributes.STEP_HEIGHT, 0.6);
|
||||
return builder;
|
||||
return Mob.createMobAttributes()
|
||||
.add(Attributes.MOVEMENT_SPEED, 0.3)
|
||||
.add(Attributes.MAX_HEALTH, 5)
|
||||
.add(Attributes.ARMOR, 0)
|
||||
.add(Attributes.ATTACK_DAMAGE, 0)
|
||||
.add(Attributes.FOLLOW_RANGE, 16)
|
||||
.add(Attributes.STEP_HEIGHT, 0.6);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +48,7 @@ public class RoosterEntity extends Animal {
|
||||
this.goalSelector.addGoal(0, new FloatGoal(this));
|
||||
this.goalSelector.addGoal(1, new PanicGoal(this, 1.4));
|
||||
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
|
||||
this.goalSelector.addGoal(3, new TemptGoal(this, 1.0, p_335679_ -> p_335679_.is(ItemTags.CHICKEN_FOOD), false));
|
||||
this.goalSelector.addGoal(3, new TemptGoal(this, 1.0, stack -> stack.is(ItemTags.CHICKEN_FOOD), false));
|
||||
this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1));
|
||||
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0));
|
||||
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
|
||||
@@ -84,37 +77,42 @@ public class RoosterEntity extends Animal {
|
||||
|
||||
@Override
|
||||
public boolean isFood(ItemStack stack) {
|
||||
return Ingredient.of(new ItemStack(Items.WHEAT_SEEDS)).test(stack);
|
||||
return stack.is(ItemTags.CHICKEN_FOOD);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public AgeableMob getBreedOffspring(ServerLevel level, AgeableMob partner) {
|
||||
return ModEntities.ROOSTER.get().create(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable AgeableMob getBreedOffspring(ServerLevel serverLevel, AgeableMob ageableMob) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void dropCustomDeathLoot(ServerLevel serverLevel, DamageSource source, boolean recentlyHitIn) {
|
||||
super.dropCustomDeathLoot(serverLevel, source, recentlyHitIn);
|
||||
protected void dropCustomDeathLoot(ServerLevel serverLevel, DamageSource source, boolean recentlyHit) {
|
||||
super.dropCustomDeathLoot(serverLevel, source, recentlyHit);
|
||||
this.spawnAtLocation(new ItemStack(Items.CHICKEN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (!this.level().isClientSide() && !level().isRaining() && !level().isThundering()) {
|
||||
long day = this.level().getDayTime() / 24000L;
|
||||
long lastDay = -1;
|
||||
if (this.lastDay != -1 && day != this.lastDay) {
|
||||
this.onNewDay();
|
||||
}
|
||||
this.lastDay = day;
|
||||
if (this.level().isClientSide()) {
|
||||
return;
|
||||
}
|
||||
|
||||
long day = this.level().getDayTime() / 24000L;
|
||||
if (this.lastDay != -1 && day != this.lastDay && !this.isBaby()) {
|
||||
this.crowDelay = this.random.nextInt(60);
|
||||
}
|
||||
this.lastDay = day;
|
||||
|
||||
if (this.crowDelay >= 0 && --this.crowDelay < 0) {
|
||||
if (this.isAlive() && !this.level().isRaining() && !this.level().isThundering()) {
|
||||
this.crow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onNewDay() {
|
||||
private void crow() {
|
||||
this.playSound(ModSounds.ROOSTER_CROW.get(), 2.0f, 0.8f + this.random.nextFloat() * 0.4f);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user