[change] change some settings for Pinguin/Rooster/Firefly
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ parchment_mappings_version=2025.12.21-nightly-SNAPSHOT
|
|||||||
# Must match the String constant located in the main mod class annotated with @Mod.
|
# Must match the String constant located in the main mod class annotated with @Mod.
|
||||||
mod_id=masterwild
|
mod_id=masterwild
|
||||||
# The human-readable display name for the mod.
|
# The human-readable display name for the mod.
|
||||||
mod_name=MasterWIld
|
mod_name=MasterWild
|
||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=All Rights Reserved
|
mod_license=All Rights Reserved
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ public class ModEntities {
|
|||||||
.sized(0.75f, 0.85f).build("pinguin"));
|
.sized(0.75f, 0.85f).build("pinguin"));
|
||||||
|
|
||||||
public static final Supplier<EntityType<FireflyEntity>> FIREFLY =
|
public static final Supplier<EntityType<FireflyEntity>> FIREFLY =
|
||||||
ENTITY_TYPES.register("firefly", () -> EntityType.Builder.of(FireflyEntity::new, MobCategory.CREATURE)
|
ENTITY_TYPES.register("firefly", () -> EntityType.Builder.of(FireflyEntity::new, MobCategory.AMBIENT)
|
||||||
.sized(0.35f, 0.5f).build("firefly"));
|
.sized(0.35f, 0.5f).build("firefly"));
|
||||||
|
|
||||||
public static final Supplier<EntityType<RoosterEntity>> ROOSTER =
|
public static final Supplier<EntityType<RoosterEntity>> ROOSTER =
|
||||||
ENTITY_TYPES.register("rooster", () -> EntityType.Builder.of(RoosterEntity::new, MobCategory.CREATURE)
|
ENTITY_TYPES.register("rooster", () -> EntityType.Builder.of(RoosterEntity::new, MobCategory.CREATURE)
|
||||||
.sized(0.5f, 0.75f).build("rooster"));
|
.sized(0.7f, 1.0f).build("rooster"));
|
||||||
|
|
||||||
public static final Supplier<EntityType<SharkEntity>> SHARK =
|
public static final Supplier<EntityType<SharkEntity>> SHARK =
|
||||||
ENTITY_TYPES.register("shark", () -> EntityType.Builder.of(SharkEntity::new, MobCategory.WATER_CREATURE)
|
ENTITY_TYPES.register("shark", () -> EntityType.Builder.of(SharkEntity::new, MobCategory.WATER_CREATURE)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package ovh.glitchlabs.masterwild.entity.client.Pinguin;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.Util;
|
import net.minecraft.Util;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -14,6 +13,8 @@ import ovh.glitchlabs.masterwild.entity.custom.PinguinEntity;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PinguinRenderer extends MobRenderer<PinguinEntity, PinguinModel<PinguinEntity>> {
|
public class PinguinRenderer extends MobRenderer<PinguinEntity, PinguinModel<PinguinEntity>> {
|
||||||
|
private static final float SHADOW = 0.25f;
|
||||||
|
private static final float BABY_SCALE = 0.45f;
|
||||||
|
|
||||||
public static final Map<PinguinVariants, ResourceLocation> LOCATION_BY_VARIANT =
|
public static final Map<PinguinVariants, ResourceLocation> LOCATION_BY_VARIANT =
|
||||||
Util.make(Maps.newEnumMap(PinguinVariants.class), map -> {
|
Util.make(Maps.newEnumMap(PinguinVariants.class), map -> {
|
||||||
@@ -24,22 +25,21 @@ public class PinguinRenderer extends MobRenderer<PinguinEntity, PinguinModel<Pin
|
|||||||
});
|
});
|
||||||
|
|
||||||
public PinguinRenderer(EntityRendererProvider.Context context) {
|
public PinguinRenderer(EntityRendererProvider.Context context) {
|
||||||
super(context, new PinguinModel<>(context.bakeLayer(PinguinModel.LAYER_LOCATION)), 0.25f);
|
super(context, new PinguinModel<>(context.bakeLayer(PinguinModel.LAYER_LOCATION)), SHADOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getTextureLocation(PinguinEntity entity) {
|
public ResourceLocation getTextureLocation(PinguinEntity entity) {
|
||||||
return ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, "textures/entity/pinguin.png");
|
return LOCATION_BY_VARIANT.get(entity.getVariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(PinguinEntity entity, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight) {
|
protected void scale(PinguinEntity entity, PoseStack poseStack, float partialTick) {
|
||||||
if (entity.isBaby()) {
|
if (entity.isBaby()) {
|
||||||
poseStack.scale(0.45f, 0.45f, 0.45f);
|
poseStack.scale(BABY_SCALE, BABY_SCALE, BABY_SCALE);
|
||||||
|
this.shadowRadius = SHADOW * BABY_SCALE;
|
||||||
} else {
|
} else {
|
||||||
poseStack.scale(1f, 1f, 1f);
|
this.shadowRadius = SHADOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.render(entity, entityYaw, partialTicks, poseStack, buffer, packedLight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+11
-11
@@ -1,7 +1,6 @@
|
|||||||
package ovh.glitchlabs.masterwild.entity.client.Rooster;
|
package ovh.glitchlabs.masterwild.entity.client.Rooster;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -9,24 +8,25 @@ import ovh.glitchlabs.masterwild.Masterwild;
|
|||||||
import ovh.glitchlabs.masterwild.entity.custom.RoosterEntity;
|
import ovh.glitchlabs.masterwild.entity.custom.RoosterEntity;
|
||||||
|
|
||||||
public class RoosterRenderer extends MobRenderer<RoosterEntity, RoosterModel<RoosterEntity>> {
|
public class RoosterRenderer extends MobRenderer<RoosterEntity, RoosterModel<RoosterEntity>> {
|
||||||
|
private static final ResourceLocation TEXTURE =
|
||||||
|
ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, "textures/entity/rooster.png");
|
||||||
|
private static final float ADULT_SCALE = 1.5f;
|
||||||
|
private static final float BABY_SCALE = 0.45f;
|
||||||
|
private static final float SHADOW = 0.25f;
|
||||||
|
|
||||||
public RoosterRenderer(EntityRendererProvider.Context context) {
|
public RoosterRenderer(EntityRendererProvider.Context context) {
|
||||||
super(context, new RoosterModel<>(context.bakeLayer(RoosterModel.LAYER_LOCATION)), 0.25f);
|
super(context, new RoosterModel<>(context.bakeLayer(RoosterModel.LAYER_LOCATION)), SHADOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getTextureLocation(RoosterEntity entity) {
|
public ResourceLocation getTextureLocation(RoosterEntity entity) {
|
||||||
return ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, "textures/entity/rooster.png");
|
return TEXTURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(RoosterEntity entity, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight) {
|
protected void scale(RoosterEntity entity, PoseStack poseStack, float partialTick) {
|
||||||
if(entity.isBaby()) {
|
float scale = entity.isBaby() ? BABY_SCALE : ADULT_SCALE;
|
||||||
poseStack.scale(0.45f, 0.45f, 0.45f);
|
poseStack.scale(scale, scale, scale);
|
||||||
} else {
|
this.shadowRadius = SHADOW * scale;
|
||||||
poseStack.scale(1.5f, 1.5f, 1.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.render(entity, entityYaw, partialTicks, poseStack, buffer, packedLight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package ovh.glitchlabs.masterwild.entity.client.firefly;
|
package ovh.glitchlabs.masterwild.entity.client.firefly;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -9,20 +7,16 @@ import ovh.glitchlabs.masterwild.Masterwild;
|
|||||||
import ovh.glitchlabs.masterwild.entity.custom.FireflyEntity;
|
import ovh.glitchlabs.masterwild.entity.custom.FireflyEntity;
|
||||||
|
|
||||||
public class FireflyRenderer extends MobRenderer<FireflyEntity, FireflyModel<FireflyEntity>> {
|
public class FireflyRenderer extends MobRenderer<FireflyEntity, FireflyModel<FireflyEntity>> {
|
||||||
|
private static final ResourceLocation TEXTURE =
|
||||||
|
ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, "textures/entity/firefly.png");
|
||||||
|
|
||||||
public FireflyRenderer(EntityRendererProvider.Context context) {
|
public FireflyRenderer(EntityRendererProvider.Context context) {
|
||||||
super(context, new FireflyModel<>(context.bakeLayer(FireflyModel.LAYER_LOCATION)), 0.50f);
|
super(context, new FireflyModel<>(context.bakeLayer(FireflyModel.LAYER_LOCATION)), 0.1f);
|
||||||
this.addLayer(new FireflyGlowLayer(this));
|
this.addLayer(new FireflyGlowLayer(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getTextureLocation(FireflyEntity entity) {
|
public ResourceLocation getTextureLocation(FireflyEntity entity) {
|
||||||
return ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, "textures/entity/firefly.png");
|
return TEXTURE;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(FireflyEntity entity, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight) {
|
|
||||||
poseStack.scale(1f, 1f, 1f);
|
|
||||||
|
|
||||||
super.render(entity, entityYaw, partialTicks, poseStack, buffer, packedLight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,38 +1,40 @@
|
|||||||
package ovh.glitchlabs.masterwild.entity.custom;
|
package ovh.glitchlabs.masterwild.entity.custom;
|
||||||
|
|
||||||
import net.minecraft.Util;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.DifficultyInstance;
|
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.entity.*;
|
import net.minecraft.world.entity.AgeableMob;
|
||||||
|
import net.minecraft.world.entity.AnimationState;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.Mob;
|
||||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.entity.ai.control.FlyingMoveControl;
|
|
||||||
import net.minecraft.world.entity.ai.goal.*;
|
|
||||||
import net.minecraft.world.entity.ai.navigation.FlyingPathNavigation;
|
|
||||||
import net.minecraft.world.entity.ai.navigation.PathNavigation;
|
|
||||||
import net.minecraft.world.entity.animal.Animal;
|
import net.minecraft.world.entity.animal.Animal;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.ServerLevelAccessor;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ovh.glitchlabs.masterwild.entity.PinguinVariants;
|
|
||||||
|
|
||||||
public class FireflyEntity extends Animal {
|
public class FireflyEntity extends Animal {
|
||||||
public static final AnimationState idleAnimationState = new AnimationState();
|
public final AnimationState idleAnimationState = new AnimationState();
|
||||||
private BlockPos targetPosition;
|
private BlockPos targetPosition;
|
||||||
|
|
||||||
public FireflyEntity(EntityType<? extends Animal> entityType, Level level) {
|
public FireflyEntity(EntityType<? extends Animal> entityType, Level level) {
|
||||||
super(entityType, level);
|
super(entityType, level);
|
||||||
xpReward = 0;
|
}
|
||||||
setNoAi(false);
|
|
||||||
|
public static AttributeSupplier.Builder createAttributes() {
|
||||||
|
return Mob.createMobAttributes()
|
||||||
|
.add(Attributes.MOVEMENT_SPEED, 0.4)
|
||||||
|
.add(Attributes.MAX_HEALTH, 4)
|
||||||
|
.add(Attributes.ARMOR, 0)
|
||||||
|
.add(Attributes.ATTACK_DAMAGE, 0)
|
||||||
|
.add(Attributes.FOLLOW_RANGE, 4)
|
||||||
|
.add(Attributes.FLYING_SPEED, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -64,9 +66,27 @@ public class FireflyEntity extends Animal {
|
|||||||
this.setDeltaMovement(newMotion);
|
this.setDeltaMovement(newMotion);
|
||||||
|
|
||||||
float targetYaw = (float) (Mth.atan2(newMotion.z, newMotion.x) * 180.0 / Math.PI) - 90.0F;
|
float targetYaw = (float) (Mth.atan2(newMotion.z, newMotion.x) * 180.0 / Math.PI) - 90.0F;
|
||||||
float yawDiff = Mth.wrapDegrees(targetYaw - this.getYRot());
|
|
||||||
this.zza = 0.5F;
|
this.zza = 0.5F;
|
||||||
this.setYRot(this.getYRot() + yawDiff);
|
this.setYRot(this.getYRot() + Mth.wrapDegrees(targetYaw - this.getYRot()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNoGravity() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPushable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean causeFallDamage(float fallDistance, float multiplier, DamageSource source) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void checkFallDamage(double y, boolean onGround, BlockState state, BlockPos pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -80,67 +100,20 @@ public class FireflyEntity extends Animal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPushable() {
|
public boolean isFood(ItemStack stack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PathNavigation createNavigation(Level world) {
|
public @Nullable AgeableMob getBreedOffspring(ServerLevel level, AgeableMob partner) {
|
||||||
return new FlyingPathNavigation(this, world);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFood(ItemStack itemStack) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable AgeableMob getBreedOffspring(ServerLevel serverLevel, AgeableMob ageableMob) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void aiStep() {
|
|
||||||
super.aiStep();
|
|
||||||
this.setNoGravity(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setNoGravity(boolean ignored) {
|
|
||||||
super.setNoGravity(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean causeFallDamage(float l, float d, DamageSource source) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkFallDamage(double y, boolean onGroundIn, BlockState state, BlockPos pos) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AttributeSupplier.Builder createAttributes() {
|
|
||||||
AttributeSupplier.Builder builder = Mob.createMobAttributes();
|
|
||||||
builder = builder.add(Attributes.MOVEMENT_SPEED, 0.4);
|
|
||||||
builder = builder.add(Attributes.MAX_HEALTH, 4);
|
|
||||||
builder = builder.add(Attributes.ARMOR, 0);
|
|
||||||
builder = builder.add(Attributes.ATTACK_DAMAGE, 0);
|
|
||||||
builder = builder.add(Attributes.FOLLOW_RANGE, 4);
|
|
||||||
builder = builder.add(Attributes.STEP_HEIGHT, 0.6);
|
|
||||||
builder = builder.add(Attributes.FLYING_SPEED, 0.3);
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupAnimationStates() {
|
|
||||||
this.idleAnimationState.startIfStopped(this.tickCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
if (this.level().isClientSide()) {
|
if (this.level().isClientSide()) {
|
||||||
this.setupAnimationStates();
|
this.idleAnimationState.startIfStopped(this.tickCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package ovh.glitchlabs.masterwild.entity.custom;
|
package ovh.glitchlabs.masterwild.entity.custom;
|
||||||
|
|
||||||
import net.minecraft.Util;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
@@ -8,98 +7,90 @@ import net.minecraft.network.syncher.SynchedEntityData;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.DifficultyInstance;
|
import net.minecraft.world.DifficultyInstance;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.entity.*;
|
import net.minecraft.world.entity.AgeableMob;
|
||||||
|
import net.minecraft.world.entity.AnimationState;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.Mob;
|
||||||
|
import net.minecraft.world.entity.MobSpawnType;
|
||||||
|
import net.minecraft.world.entity.SpawnGroupData;
|
||||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.entity.ai.goal.*;
|
import net.minecraft.world.entity.ai.goal.*;
|
||||||
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
|
|
||||||
import net.minecraft.world.entity.animal.Animal;
|
import net.minecraft.world.entity.animal.Animal;
|
||||||
import net.minecraft.world.entity.animal.Cod;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.ServerLevelAccessor;
|
import net.minecraft.world.level.ServerLevelAccessor;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ovh.glitchlabs.masterwild.entity.ModEntities;
|
import ovh.glitchlabs.masterwild.entity.ModEntities;
|
||||||
import ovh.glitchlabs.masterwild.entity.PinguinVariants;
|
import ovh.glitchlabs.masterwild.entity.PinguinVariants;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class PinguinEntity extends Animal {
|
public class PinguinEntity extends Animal {
|
||||||
public static final AnimationState idleAnimationState = new AnimationState();
|
private static final Ingredient FOOD = Ingredient.of(Items.COD, Items.SALMON);
|
||||||
private int idleAnimationTimeout = 0;
|
private static final float RARE_CHANCE = 0.1f;
|
||||||
|
|
||||||
private static final EntityDataAccessor<Integer> VARIANT =
|
private static final EntityDataAccessor<Integer> VARIANT =
|
||||||
SynchedEntityData.defineId(PinguinEntity.class, EntityDataSerializers.INT);
|
SynchedEntityData.defineId(PinguinEntity.class, EntityDataSerializers.INT);
|
||||||
|
|
||||||
|
public final AnimationState idleAnimationState = new AnimationState();
|
||||||
|
|
||||||
public PinguinEntity(EntityType<? extends Animal> entityType, Level level) {
|
public PinguinEntity(EntityType<? extends Animal> entityType, Level level) {
|
||||||
super(entityType, level);
|
super(entityType, level);
|
||||||
xpReward = 0;
|
|
||||||
setNoAi(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AttributeSupplier.Builder createAttributes() {
|
public static AttributeSupplier.Builder createAttributes() {
|
||||||
AttributeSupplier.Builder builder = Mob.createMobAttributes();
|
return Mob.createMobAttributes()
|
||||||
builder = builder.add(Attributes.MOVEMENT_SPEED, 0.3);
|
.add(Attributes.MOVEMENT_SPEED, 0.3)
|
||||||
builder = builder.add(Attributes.MAX_HEALTH, 6);
|
.add(Attributes.MAX_HEALTH, 6)
|
||||||
builder = builder.add(Attributes.ARMOR, 0);
|
.add(Attributes.ARMOR, 0)
|
||||||
builder = builder.add(Attributes.ATTACK_DAMAGE, 3);
|
.add(Attributes.ATTACK_DAMAGE, 3)
|
||||||
builder = builder.add(Attributes.FOLLOW_RANGE, 4);
|
.add(Attributes.FOLLOW_RANGE, 4)
|
||||||
builder = builder.add(Attributes.STEP_HEIGHT, 0.6);
|
.add(Attributes.STEP_HEIGHT, 0.6);
|
||||||
return builder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFood(ItemStack stack) {
|
public boolean isFood(ItemStack stack) {
|
||||||
return Ingredient.of(new ItemStack(Items.COD)).test(stack);
|
return FOOD.test(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerGoals() {
|
protected void registerGoals() {
|
||||||
super.registerGoals();
|
super.registerGoals();
|
||||||
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1, false) {
|
this.goalSelector.addGoal(0, new FloatGoal(this));
|
||||||
@Override
|
this.goalSelector.addGoal(1, new PanicGoal(this, 1.0));
|
||||||
protected boolean canPerformAttack(LivingEntity entity) {
|
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
|
||||||
return this.isTimeToAttack() && this.mob.distanceToSqr(entity) < (this.mob.getBbWidth() * this.mob.getBbWidth() + entity.getBbWidth()) && this.mob.getSensing().hasLineOfSight(entity);
|
this.goalSelector.addGoal(3, new TemptGoal(this, 1.0, FOOD, false));
|
||||||
}
|
this.goalSelector.addGoal(4, new FollowParentGoal(this, 0.8));
|
||||||
});
|
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 0.8));
|
||||||
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, Cod.class, true, true));
|
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
|
||||||
this.goalSelector.addGoal(3, new WaterAvoidingRandomStrollGoal(this, 0.8));
|
|
||||||
this.goalSelector.addGoal(4, new PanicGoal(this, 1));
|
|
||||||
this.goalSelector.addGoal(5, new FollowParentGoal(this, 0.8));
|
|
||||||
this.goalSelector.addGoal(6, new BreedGoal(this, 1));
|
|
||||||
this.goalSelector.addGoal(7, new RandomLookAroundGoal(this));
|
this.goalSelector.addGoal(7, new RandomLookAroundGoal(this));
|
||||||
this.goalSelector.addGoal(8, new FloatGoal(this));
|
|
||||||
this.goalSelector.addGoal(10, new TemptGoal(this, 1, (Ingredient.of(Items.COD, Items.SALMON)), false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void dropCustomDeathLoot(ServerLevel serverLevel, DamageSource source, boolean recentlyHitIn) {
|
@Override
|
||||||
super.dropCustomDeathLoot(serverLevel, source, recentlyHitIn);
|
protected void dropCustomDeathLoot(ServerLevel serverLevel, DamageSource source, boolean recentlyHit) {
|
||||||
|
super.dropCustomDeathLoot(serverLevel, source, recentlyHit);
|
||||||
this.spawnAtLocation(new ItemStack(Items.COD));
|
this.spawnAtLocation(new ItemStack(Items.COD));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) {
|
public AgeableMob getBreedOffspring(ServerLevel level, AgeableMob partner) {
|
||||||
PinguinEntity retval = ModEntities.PINGUIN.get().create(serverWorld);
|
PinguinEntity baby = ModEntities.PINGUIN.get().create(level);
|
||||||
retval.finalizeSpawn(serverWorld, serverWorld.getCurrentDifficultyAt(retval.blockPosition()), MobSpawnType.BREEDING, null);
|
if (baby != null) {
|
||||||
return retval;
|
baby.finalizeSpawn(level, level.getCurrentDifficultyAt(baby.blockPosition()), MobSpawnType.BREEDING, null);
|
||||||
}
|
PinguinEntity other = partner instanceof PinguinEntity p ? p : this;
|
||||||
|
baby.setVariant(this.random.nextBoolean() ? this.getVariant() : other.getVariant());
|
||||||
private void setupAnimationStates() {
|
|
||||||
if(this.idleAnimationTimeout <= 0) {
|
|
||||||
this.idleAnimationTimeout = 5;
|
|
||||||
this.idleAnimationState.start(this.tickCount);
|
|
||||||
} else {
|
|
||||||
--this.idleAnimationTimeout;
|
|
||||||
}
|
}
|
||||||
|
return baby;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
if (this.level().isClientSide()) {
|
if (this.level().isClientSide()) {
|
||||||
this.setupAnimationStates();
|
this.idleAnimationState.startIfStopped(this.tickCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,9 +127,7 @@ public class PinguinEntity extends Animal {
|
|||||||
@Override
|
@Override
|
||||||
public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty,
|
public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty,
|
||||||
MobSpawnType spawnType, @Nullable SpawnGroupData spawnGroupData) {
|
MobSpawnType spawnType, @Nullable SpawnGroupData spawnGroupData) {
|
||||||
PinguinVariants variants = Util.getRandom(PinguinVariants.values(), this.random);
|
this.setVariant(this.random.nextFloat() < RARE_CHANCE ? PinguinVariants.RARE : PinguinVariants.NORMAL);
|
||||||
this.setVariant(variants);
|
|
||||||
return super.finalizeSpawn(level, difficulty, spawnType, spawnGroupData);
|
return super.finalizeSpawn(level, difficulty, spawnType, spawnGroupData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
package ovh.glitchlabs.masterwild.entity.custom;
|
package ovh.glitchlabs.masterwild.entity.custom;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.tags.ItemTags;
|
import net.minecraft.tags.ItemTags;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.entity.AgeableMob;
|
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.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.pathfinder.PathType;
|
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 org.jetbrains.annotations.Nullable;
|
||||||
import ovh.glitchlabs.masterwild.Sounds.ModSounds;
|
import ovh.glitchlabs.masterwild.Sounds.ModSounds;
|
||||||
|
import ovh.glitchlabs.masterwild.entity.ModEntities;
|
||||||
|
|
||||||
public class RoosterEntity extends Animal {
|
public class RoosterEntity extends Animal {
|
||||||
|
// -1 = noch kein Tag erfasst -> beim Laden/Betreten der Welt wird nicht gekräht
|
||||||
boolean newDay = false;
|
private long lastDay = -1;
|
||||||
private long lastDay;
|
private int crowDelay = -1;
|
||||||
|
|
||||||
public RoosterEntity(EntityType<? extends Animal> entityType, Level level) {
|
public RoosterEntity(EntityType<? extends Animal> entityType, Level level) {
|
||||||
super(entityType, level);
|
super(entityType, level);
|
||||||
xpReward = 10;
|
|
||||||
setNoAi(false);
|
|
||||||
this.setPathfindingMalus(PathType.WATER, 0.0F);
|
this.setPathfindingMalus(PathType.WATER, 0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AttributeSupplier.Builder createAttributes() {
|
public static AttributeSupplier.Builder createAttributes() {
|
||||||
AttributeSupplier.Builder builder = Mob.createMobAttributes();
|
return Mob.createMobAttributes()
|
||||||
builder = builder.add(Attributes.MOVEMENT_SPEED, 0.3);
|
.add(Attributes.MOVEMENT_SPEED, 0.3)
|
||||||
builder = builder.add(Attributes.MAX_HEALTH, 5);
|
.add(Attributes.MAX_HEALTH, 5)
|
||||||
builder = builder.add(Attributes.ARMOR, 0);
|
.add(Attributes.ARMOR, 0)
|
||||||
builder = builder.add(Attributes.ATTACK_DAMAGE, 0);
|
.add(Attributes.ATTACK_DAMAGE, 0)
|
||||||
builder = builder.add(Attributes.FOLLOW_RANGE, 16);
|
.add(Attributes.FOLLOW_RANGE, 16)
|
||||||
builder = builder.add(Attributes.STEP_HEIGHT, 0.6);
|
.add(Attributes.STEP_HEIGHT, 0.6);
|
||||||
return builder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,7 +48,7 @@ public class RoosterEntity extends Animal {
|
|||||||
this.goalSelector.addGoal(0, new FloatGoal(this));
|
this.goalSelector.addGoal(0, new FloatGoal(this));
|
||||||
this.goalSelector.addGoal(1, new PanicGoal(this, 1.4));
|
this.goalSelector.addGoal(1, new PanicGoal(this, 1.4));
|
||||||
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
|
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(4, new FollowParentGoal(this, 1.1));
|
||||||
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0));
|
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0));
|
||||||
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
|
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
|
||||||
@@ -84,37 +77,42 @@ public class RoosterEntity extends Animal {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFood(ItemStack stack) {
|
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
|
@Override
|
||||||
public @Nullable AgeableMob getBreedOffspring(ServerLevel serverLevel, AgeableMob ageableMob) {
|
protected void dropCustomDeathLoot(ServerLevel serverLevel, DamageSource source, boolean recentlyHit) {
|
||||||
return null;
|
super.dropCustomDeathLoot(serverLevel, source, recentlyHit);
|
||||||
}
|
|
||||||
|
|
||||||
protected void dropCustomDeathLoot(ServerLevel serverLevel, DamageSource source, boolean recentlyHitIn) {
|
|
||||||
super.dropCustomDeathLoot(serverLevel, source, recentlyHitIn);
|
|
||||||
this.spawnAtLocation(new ItemStack(Items.CHICKEN));
|
this.spawnAtLocation(new ItemStack(Items.CHICKEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if (!this.level().isClientSide() && !level().isRaining() && !level().isThundering()) {
|
if (this.level().isClientSide()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
long day = this.level().getDayTime() / 24000L;
|
long day = this.level().getDayTime() / 24000L;
|
||||||
long lastDay = -1;
|
if (this.lastDay != -1 && day != this.lastDay && !this.isBaby()) {
|
||||||
if (this.lastDay != -1 && day != this.lastDay) {
|
this.crowDelay = this.random.nextInt(60);
|
||||||
this.onNewDay();
|
|
||||||
}
|
}
|
||||||
this.lastDay = day;
|
this.lastDay = day;
|
||||||
|
|
||||||
|
if (this.crowDelay >= 0 && --this.crowDelay < 0) {
|
||||||
|
if (this.isAlive() && !this.level().isRaining() && !this.level().isThundering()) {
|
||||||
|
this.crow();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private void crow() {
|
||||||
|
|
||||||
private void onNewDay() {
|
|
||||||
this.playSound(ModSounds.ROOSTER_CROW.get(), 2.0f, 0.8f + this.random.nextFloat() * 0.4f);
|
this.playSound(ModSounds.ROOSTER_CROW.get(), 2.0f, 0.8f + this.random.nextFloat() * 0.4f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user