From d7a0b0d265f708fe4b19c3686f2edc7dd699bf08 Mon Sep 17 00:00:00 2001 From: itsmeow Date: Wed, 22 Feb 2023 22:41:03 -0600 Subject: [PATCH] Add alligators and improve crocodilian AI a bit --- .../client/ClientLifecycleHandler.java | 2 + .../client/model/entity/ModelAlligator.java | 128 ++++++++++++++++++ .../common/entity/EntityAlligator.java | 29 ++++ .../common/entity/EntityCrocodile.java | 8 +- .../util/abstracts/EntityCrocidilian.java | 81 ++++++++++- .../betteranimalsplus/init/ModEntities.java | 11 ++ .../assets/betteranimalsplus/lang/en_us.json | 1 + .../models/item/alligator_spawn_egg.json | 3 + .../textures/entity/alligator_albino.png | Bin 0 -> 3126 bytes .../textures/entity/alligator_american.png | Bin 0 -> 3364 bytes 10 files changed, 254 insertions(+), 9 deletions(-) create mode 100644 common/src/main/java/dev/itsmeow/betteranimalsplus/client/model/entity/ModelAlligator.java create mode 100644 common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityAlligator.java create mode 100644 common/src/main/resources/assets/betteranimalsplus/models/item/alligator_spawn_egg.json create mode 100644 common/src/main/resources/assets/betteranimalsplus/textures/entity/alligator_albino.png create mode 100644 common/src/main/resources/assets/betteranimalsplus/textures/entity/alligator_american.png diff --git a/common/src/main/java/dev/itsmeow/betteranimalsplus/client/ClientLifecycleHandler.java b/common/src/main/java/dev/itsmeow/betteranimalsplus/client/ClientLifecycleHandler.java index 7f94d1e3..91d9c368 100644 --- a/common/src/main/java/dev/itsmeow/betteranimalsplus/client/ClientLifecycleHandler.java +++ b/common/src/main/java/dev/itsmeow/betteranimalsplus/client/ClientLifecycleHandler.java @@ -215,6 +215,7 @@ public static void registerEntityRenders() { .mEntry(ModelGazelle::new, "erlanger_gazelle") .mEntry(ModelGazelle::new, "springbok_gazelle")); R.addRender(ModEntities.CROCODILE::getEntityType, 0.8F, r -> r.tVariant().mSingle(ModelCrocodile::new, "crocodile").childScale(0.6F)); + R.addRender(ModEntities.ALLIGATOR::getEntityType, 0.8F, r -> r.tVariant().mSingle(ModelAlligator::new, "alligator").childScale(0.6F)); RenderFactory.addRender(ModEntities.PROJECTILE_BADGER_DIRT::get, RenderFactory.nothing()); } @@ -255,6 +256,7 @@ public static void layerDefinitions(ImmutableMap.Builder extends ModelBAP { + + public ModelPart butt; + public ModelPart chest; + public ModelPart neck; + public ModelPart head; + public ModelPart topJaw; + public ModelPart snout; + public ModelPart cranium; + public ModelPart lowJaw; + public ModelPart lowJaw2; + public ModelPart lArm1; + public ModelPart lArm2; + public ModelPart lFoot; + public ModelPart rArm1; + public ModelPart rArm2; + public ModelPart rHand; + public ModelPart tail1; + public ModelPart tail2; + public ModelPart tail3; + public ModelPart tail4; + public ModelPart tail5; + public ModelPart tail6; + public ModelPart lLeg1; + public ModelPart lLeg2; + public ModelPart lFoot2; + public ModelPart rLeg; + public ModelPart rLeg2; + public ModelPart rFoot; + + public ModelAlligator(ModelPart root) { + this.butt = root.getChild("butt"); + this.chest = butt.getChild("chest"); + this.neck = chest.getChild("neck"); + this.head = neck.getChild("head"); + this.topJaw = head.getChild("topJaw"); + this.snout = topJaw.getChild("snout"); + this.cranium = snout.getChild("cranium"); + this.lowJaw = head.getChild("lowJaw"); + this.lowJaw2 = lowJaw.getChild("lowJaw2"); + this.lArm1 = chest.getChild("lArm1"); + this.lArm2 = lArm1.getChild("lArm2"); + this.lFoot = lArm2.getChild("lFoot"); + this.rArm1 = chest.getChild("rArm1"); + this.rArm2 = rArm1.getChild("rArm2"); + this.rHand = rArm2.getChild("rHand"); + this.tail1 = butt.getChild("tail1"); + this.tail2 = tail1.getChild("tail2"); + this.tail3 = tail2.getChild("tail3"); + this.tail4 = tail3.getChild("tail4"); + this.tail5 = tail4.getChild("tail5"); + this.tail6 = tail5.getChild("tail6"); + this.lLeg1 = butt.getChild("lLeg1"); + this.lLeg2 = lLeg1.getChild("lLeg2"); + this.lFoot2 = lLeg2.getChild("lFoot2"); + this.rLeg = butt.getChild("rLeg"); + this.rLeg2 = rLeg.getChild("rLeg2"); + this.rFoot = rLeg2.getChild("rFoot"); + } + + public static LayerDefinition createBodyLayer() { + MeshDefinition meshdefinition = new MeshDefinition(); + PartDefinition partdefinition = meshdefinition.getRoot(); + PartDefinition butt = partdefinition.addOrReplaceChild("butt", CubeListBuilder.create().texOffs(0, 0).addBox(-7.0F, -2.0F, -0.1F, 14.0F, 10.0F, 16.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 15.5F, -7.5F)); + PartDefinition chest = butt.addOrReplaceChild("chest", CubeListBuilder.create().texOffs(0, 26).addBox(-6.5F, 0.0F, -12.0F, 13.0F, 9.0F, 11.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -1.7F, 1.3F, 0.0911F, 0.0F, 0.0F)); + PartDefinition neck = chest.addOrReplaceChild("neck", CubeListBuilder.create().texOffs(0, 46).addBox(-4.5F, -1.0F, -8.0F, 9.0F, 8.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 1.0F, -11.2F, 0.0456F, 0.0F, 0.0F)); + PartDefinition head = neck.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 62).addBox(-4.5F, -2.0F, -4.0F, 9.0F, 5.0F, 4.0F, new CubeDeformation(0.01F)), PartPose.offsetAndRotation(0.0F, 1.0F, -7.5F, -0.0911F, 0.0F, 0.0F)); + PartDefinition topJaw = head.addOrReplaceChild("topJaw", CubeListBuilder.create().texOffs(0, 72).addBox(-3.5F, -2.0F, -12.0F, 7.0F, 2.0F, 12.0F, new CubeDeformation(0.0F)) + .texOffs(28, 59).addBox(-3.5F, 0.0F, -12.0F, 7.0F, 1.0F, 12.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 3.0F, -3.9F)); + PartDefinition snout = topJaw.addOrReplaceChild("snout", CubeListBuilder.create().texOffs(0, 95).addBox(-3.0F, -3.0F, -2.0F, 6.0F, 1.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, -9.7F)); + PartDefinition cranium = snout.addOrReplaceChild("cranium", CubeListBuilder.create().texOffs(0, 100).addBox(-3.0F, 0.0F, 0.0F, 6.0F, 2.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -2.8F, 0.0F, 0.1227F, 0.0F, 0.0F)); + PartDefinition lowJaw = head.addOrReplaceChild("lowJaw", CubeListBuilder.create().texOffs(0, 116).addBox(-4.5F, 0.0F, -4.0F, 9.0F, 2.0F, 4.0F, new CubeDeformation(-0.001F)), PartPose.offset(0.0F, 2.9F, 0.0F)); + PartDefinition lowJaw2 = lowJaw.addOrReplaceChild("lowJaw2", CubeListBuilder.create().texOffs(42, 149).addBox(-3.0F, 0.0F, -11.75F, 6.0F, 2.0F, 12.0F, new CubeDeformation(0.0F)) + .texOffs(39, 130).addBox(-3.0F, -1.0F, -11.75F, 6.0F, 1.0F, 12.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, -3.9F)); + PartDefinition lArm1 = chest.addOrReplaceChild("lArm1", CubeListBuilder.create().texOffs(46, 0).mirror().addBox(-2.0F, -1.0F, -2.0F, 4.0F, 7.0F, 4.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(6.0F, 6.0F, -7.0F, 0.0F, 0.0F, -1.309F)); + PartDefinition lArm2 = lArm1.addOrReplaceChild("lArm2", CubeListBuilder.create().texOffs(63, 0).mirror().addBox(-1.5F, 0.158F, -1.9263F, 3.0F, 7.0F, 3.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(0.0F, 5.5F, 0.75F, -1.2298F, 0.0F, 0.0F)); + PartDefinition lFoot = lArm2.addOrReplaceChild("lFoot", CubeListBuilder.create().texOffs(72, 10).addBox(-2.0F, -0.25F, -4.0F, 4.0F, 1.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 7.0F, 0.0F, 0.4887F, -1.0996F, 1.1519F)); + PartDefinition rArm1 = chest.addOrReplaceChild("rArm1", CubeListBuilder.create().texOffs(46, 0).addBox(-2.0F, -1.0F, -2.0F, 4.0F, 7.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-6.0F, 6.0F, -7.0F, 0.0F, 0.0F, 1.309F)); + PartDefinition rArm2 = rArm1.addOrReplaceChild("rArm2", CubeListBuilder.create().texOffs(63, 0).addBox(-1.5F, 0.158F, -1.9263F, 3.0F, 7.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 5.5F, 0.75F, -1.2298F, 0.0F, 0.0F)); + PartDefinition rHand = rArm2.addOrReplaceChild("rHand", CubeListBuilder.create().texOffs(72, 10).addBox(-2.0F, -0.25F, -4.0F, 4.0F, 1.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 7.0F, 0.0F, 0.4887F, 1.0996F, -1.1519F)); + PartDefinition tail1 = butt.addOrReplaceChild("tail1", CubeListBuilder.create().texOffs(0, 146).addBox(-6.0F, -4.5F, 0.0F, 12.0F, 9.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 3.0F, 15.0F, -0.1367F, 0.0F, 0.0F)); + PartDefinition tail2 = tail1.addOrReplaceChild("tail2", CubeListBuilder.create().texOffs(0, 162).addBox(-5.0F, -4.0F, 0.0F, 10.0F, 8.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, -0.5F, 6.7F)); + PartDefinition tail3 = tail2.addOrReplaceChild("tail3", CubeListBuilder.create().texOffs(0, 179).addBox(-4.0F, -3.5F, 0.0F, 8.0F, 7.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, -0.5F, 8.7F)); + PartDefinition tail4 = tail3.addOrReplaceChild("tail4", CubeListBuilder.create().texOffs(0, 195).addBox(-3.5F, -3.0F, 0.0F, 7.0F, 6.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -0.5F, 8.7F, 0.0456F, 0.0F, 0.0F)); + PartDefinition tail5 = tail4.addOrReplaceChild("tail5", CubeListBuilder.create().texOffs(0, 210).addBox(-2.5F, -2.5F, 0.0F, 5.0F, 5.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -0.5F, 8.7F, -0.0456F, 0.0F, 0.0F)); + PartDefinition tail6 = tail5.addOrReplaceChild("tail6", CubeListBuilder.create().texOffs(0, 223).addBox(-1.5F, -2.0F, 0.0F, 3.0F, 4.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, -0.5F, 7.7F)); + PartDefinition tailSpikesL6 = tail6.addOrReplaceChild("tailSpikesL6", CubeListBuilder.create().texOffs(47, 105).addBox(0.0F, -3.0F, 0.0F, 0.0F, 4.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-1.0F, -2.7F, 0.0F, 0.0F, 0.0911F, 0.0F)); + PartDefinition tailSpikesR6 = tail6.addOrReplaceChild("tailSpikesR6", CubeListBuilder.create().texOffs(47, 105).addBox(0.0F, -3.0F, 0.0F, 0.0F, 4.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(1.0F, -2.7F, 0.0F, 0.0F, -0.0911F, 0.0F)); + PartDefinition tailSpikesL5 = tail5.addOrReplaceChild("tailSpikesL5", CubeListBuilder.create().texOffs(47, 92).addBox(0.0F, -3.0F, 0.0F, 0.0F, 4.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-2.0F, -3.2F, 0.0F, 0.0F, 0.0911F, 0.0F)); + PartDefinition tailSpikesR5 = tail5.addOrReplaceChild("tailSpikesR5", CubeListBuilder.create().texOffs(47, 92).addBox(0.0F, -3.0F, 0.0F, 0.0F, 4.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(2.0F, -3.2F, 0.0F, 0.0F, -0.0911F, 0.0F)); + PartDefinition tailSpikesL4 = tail4.addOrReplaceChild("tailSpikesL4", CubeListBuilder.create().texOffs(57, 84).addBox(0.0F, -3.0F, 0.0F, 0.0F, 4.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-3.0F, -3.8F, 0.0F, 0.0F, 0.0911F, 0.0F)); + PartDefinition tailSpikesR4 = tail4.addOrReplaceChild("tailSpikesR4", CubeListBuilder.create().texOffs(57, 84).addBox(0.0F, -3.0F, 0.0F, 0.0F, 4.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(3.0F, -3.8F, 0.0F, 0.0F, -0.0911F, 0.0F)); + PartDefinition tailSpikesL3 = tail3.addOrReplaceChild("tailSpikesL3", CubeListBuilder.create().texOffs(27, 96).addBox(0.0F, -2.0F, 0.0F, 0.0F, 3.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-3.5F, -4.2F, 0.0F, 0.0F, 0.0911F, 0.0F)); + PartDefinition tailSpikesR3 = tail3.addOrReplaceChild("tailSpikesR3", CubeListBuilder.create().texOffs(27, 96).addBox(0.0F, -2.0F, 0.0F, 0.0F, 3.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(3.5F, -4.2F, 0.0F, 0.0F, -0.0911F, 0.0F)); + PartDefinition tailSpikesL2 = tail2.addOrReplaceChild("tailSpikesL2", CubeListBuilder.create().texOffs(32, 80).addBox(0.0F, -2.0F, 0.0F, 0.0F, 3.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-4.5F, -4.8F, 0.0F, 0.0F, 0.0911F, 0.0F)); + PartDefinition tailSpikesR2 = tail2.addOrReplaceChild("tailSpikesR2", CubeListBuilder.create().texOffs(32, 80).addBox(0.0F, -2.0F, 0.0F, 0.0F, 3.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(4.1F, -4.8F, 0.0F, 0.0F, -0.0911F, 0.0F)); + PartDefinition tailSpikesL1 = tail1.addOrReplaceChild("tailSpikesL1", CubeListBuilder.create().texOffs(20, 87).addBox(0.0F, -2.0F, 0.0F, 0.0F, 3.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-5.2F, -5.0F, 0.0F, 0.0F, 0.0911F, 0.0F)); + PartDefinition tailSpikesR1 = tail1.addOrReplaceChild("tailSpikesR1", CubeListBuilder.create().texOffs(20, 87).addBox(0.0F, -2.0F, 0.0F, 0.0F, 3.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(4.8F, -5.0F, 0.0F, 0.0F, -0.0911F, 0.0F)); + PartDefinition lLeg1 = butt.addOrReplaceChild("lLeg1", CubeListBuilder.create().texOffs(58, 23).addBox(-3.0F, 0.0F, -2.5F, 5.0F, 8.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(7.0F, 1.0F, 15.5F, -1.0908F, 0.0F, -0.5672F)); + PartDefinition lLeg2 = lLeg1.addOrReplaceChild("lLeg2", CubeListBuilder.create().texOffs(51, 40).addBox(-2.0F, 0.0F, -1.5F, 4.0F, 8.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-0.5F, 7.5F, -0.25F, 1.9635F, 0.0F, 0.0F)); + PartDefinition lFoot2 = lLeg2.addOrReplaceChild("lFoot2", CubeListBuilder.create().texOffs(66, 40).addBox(-2.5F, 0.0F, -5.75F, 5.0F, 1.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 7.75F, 1.5F, -0.6109F, -0.1396F, 0.8727F)); + PartDefinition rLeg = butt.addOrReplaceChild("rLeg", CubeListBuilder.create().texOffs(58, 23).addBox(-3.0F, 0.0F, -2.5F, 5.0F, 8.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-6.0F, 1.5F, 15.5F, -1.0908F, 0.0F, 0.5672F)); + PartDefinition rLeg2 = rLeg.addOrReplaceChild("rLeg2", CubeListBuilder.create().texOffs(51, 40).addBox(-2.0F, 0.0F, -1.5F, 4.0F, 8.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-0.5F, 7.5F, -0.25F, 1.9635F, 0.0F, 0.0F)); + PartDefinition rFoot = rLeg2.addOrReplaceChild("rFoot", CubeListBuilder.create().texOffs(66, 40).addBox(-2.5F, 0.0F, -5.75F, 5.0F, 1.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 7.75F, 1.5F, -0.6109F, 0.1396F, -0.8727F)); + return LayerDefinition.create(meshdefinition, 90, 256); + } + + @Override + public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { + butt.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha); + } + + @Override + public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { + + } + +} \ No newline at end of file diff --git a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityAlligator.java b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityAlligator.java new file mode 100644 index 00000000..3f8204cf --- /dev/null +++ b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityAlligator.java @@ -0,0 +1,29 @@ +package dev.itsmeow.betteranimalsplus.common.entity; + +import dev.itsmeow.betteranimalsplus.common.entity.util.abstracts.EntityAnimalWithTypes; +import dev.itsmeow.betteranimalsplus.common.entity.util.abstracts.EntityCrocidilian; +import dev.itsmeow.betteranimalsplus.init.ModEntities; +import dev.itsmeow.imdlib.entity.EntityTypeContainer; +import dev.itsmeow.imdlib.entity.util.variant.IVariant; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.Level; + +public class EntityAlligator extends EntityCrocidilian { + + public EntityAlligator(EntityType entityType, Level level) { + super(entityType, level); + } + + @Override + public EntityTypeContainer getContainer() { + return ModEntities.ALLIGATOR; + } + + @Override + public IVariant getRandomType() { + if(this.getRandom().nextFloat() <= 0.125F) { + return getContainer().getVariantForName("albino").orElse(null); + } + return getContainer().getVariantForName("american").orElse(null); + } +} diff --git a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityCrocodile.java b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityCrocodile.java index 850db5e6..1485e8a3 100644 --- a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityCrocodile.java +++ b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/EntityCrocodile.java @@ -1,7 +1,7 @@ package dev.itsmeow.betteranimalsplus.common.entity; +import dev.itsmeow.betteranimalsplus.common.entity.util.abstracts.EntityAnimalWithTypes; import dev.itsmeow.betteranimalsplus.common.entity.util.abstracts.EntityCrocidilian; -import dev.itsmeow.betteranimalsplus.common.entity.util.abstracts.EntityWaterMobPathing; import dev.itsmeow.betteranimalsplus.init.ModEntities; import dev.itsmeow.imdlib.entity.EntityTypeContainer; import dev.itsmeow.imdlib.entity.interfaces.ISelectiveVariantTypes; @@ -14,17 +14,17 @@ import java.util.Set; -public class EntityCrocodile extends EntityCrocidilian implements ISelectiveVariantTypes { +public class EntityCrocodile extends EntityCrocidilian implements ISelectiveVariantTypes { private static final String[] ALL_TYPE = {"american", "nile"}; private static final String[] SAVANNA_TYPE = {"nile"}; - public EntityCrocodile(EntityType entityType, Level level) { + public EntityCrocodile(EntityType entityType, Level level) { super(entityType, level); } @Override - public EntityTypeContainer getContainer() { + public EntityTypeContainer getContainer() { return ModEntities.CROCODILE; } diff --git a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/util/abstracts/EntityCrocidilian.java b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/util/abstracts/EntityCrocidilian.java index 91c39005..702b25bb 100644 --- a/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/util/abstracts/EntityCrocidilian.java +++ b/common/src/main/java/dev/itsmeow/betteranimalsplus/common/entity/util/abstracts/EntityCrocidilian.java @@ -1,26 +1,36 @@ package dev.itsmeow.betteranimalsplus.common.entity.util.abstracts; +import dev.itsmeow.betteranimalsplus.common.entity.ai.HybridMoveController; +import dev.itsmeow.betteranimalsplus.common.entity.ai.HybridPathNavigator; import dev.itsmeow.betteranimalsplus.common.entity.ai.PeacefulNearestAttackableTargetGoal; import dev.itsmeow.betteranimalsplus.common.entity.util.IPeacefulAware; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.Difficulty; +import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.ai.control.SmoothSwimmingLookControl; -import net.minecraft.world.entity.ai.control.SmoothSwimmingMoveControl; +import net.minecraft.world.entity.MobType; +import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.ai.goal.BreathAirGoal; import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal; import net.minecraft.world.entity.ai.goal.TryFindWaterGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; +import net.minecraft.world.entity.ai.navigation.PathNavigation; import net.minecraft.world.entity.monster.Enemy; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; +import net.minecraft.world.level.pathfinder.BlockPathTypes; +import net.minecraft.world.phys.Vec3; -public abstract class EntityCrocidilian extends EntityWaterMobPathingWithTypesAirBreathing implements Enemy, IPeacefulAware { +public abstract class EntityCrocidilian extends EntityAnimalWithTypes implements Enemy, IPeacefulAware { public EntityCrocidilian(EntityType entityType, Level level) { super(entityType, level); - this.moveControl = new SmoothSwimmingMoveControl(this, 25, 7, 1F, 1F, true); - this.lookControl = new SmoothSwimmingLookControl(this, 12); + this.setPathfindingMalus(BlockPathTypes.WALKABLE, 1.5F); + this.setPathfindingMalus(BlockPathTypes.WATER, 1.5F); + this.setPathfindingMalus(BlockPathTypes.WATER_BORDER, 1F); + this.moveControl = new HybridMoveController(this); + this.maxUpStep = 1F; } @Override @@ -42,4 +52,65 @@ public boolean canUse() { public boolean isPeaceful() { return this.level.getDifficulty() == Difficulty.PEACEFUL; } + + @Override + protected PathNavigation createNavigation(Level worldIn) { + return new HybridPathNavigator<>(this, worldIn, e -> e.getTarget() == null || (e.getTarget().isInWater() && this.isInWater()) || (!e.getTarget().isInWater() && this.isInWater())); + } + + @Override + public void travel(Vec3 moveVec) { + if(this.isEffectiveAi() && this.isInWater()) { + this.moveRelative(0.1F, moveVec); + this.move(MoverType.SELF, this.getDeltaMovement()); + this.setDeltaMovement(this.getDeltaMovement().scale(0.9D)); + if(this.getTarget() == null) { + this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.005D, 0.0D)); + } + } else { + super.travel(moveVec); + } + + } + + @Override + public boolean canBeLeashed(Player player) { + return false; + } + + @Override + public int getMaxAirSupply() { + return 4800; + } + + @Override + protected int increaseAirSupply(int currentAir) { + return this.getMaxAirSupply(); + } + + @Override + public boolean canBreatheUnderwater() { + return false; + } + + @Override + public boolean isPushedByFluid() { + return false; + } + + @Override + public MobType getMobType() { + return MobType.WATER; + } + + @Override + public AgeableMob getBreedOffspring(ServerLevel world, AgeableMob ageable) { + return null; + } + + @Override + protected EntityAnimalWithTypes getBaseChild() { + return null; + } + } diff --git a/common/src/main/java/dev/itsmeow/betteranimalsplus/init/ModEntities.java b/common/src/main/java/dev/itsmeow/betteranimalsplus/init/ModEntities.java index 9618a390..48d4a1f3 100644 --- a/common/src/main/java/dev/itsmeow/betteranimalsplus/init/ModEntities.java +++ b/common/src/main/java/dev/itsmeow/betteranimalsplus/init/ModEntities.java @@ -511,6 +511,17 @@ public class ModEntities { .size(2.2F, 0.8F) .biomesOverworld(BiomeTypes.SWAMP, BiomeTypes.SAVANNA) .variants("american", "nile")); + public static final EntityTypeContainer ALLIGATOR = H.add(EntityAlligator.class, EntityAlligator::new, "alligator", () -> Mob.createMobAttributes() + .add(Attributes.MAX_HEALTH, 25.0D) + .add(Attributes.MOVEMENT_SPEED, 1.2D) + .add(Attributes.ATTACK_DAMAGE) + .add(Attributes.ATTACK_DAMAGE, 3D), b -> b + .spawn(MobCategory.WATER_CREATURE, 3, 1, 3) + .waterPlacement() + .egg(0x113d0c, 0x362f21) + .size(2.2F, 0.8F) + .biomesOverworld(BiomeTypes.SWAMP) + .variants("american", "albino")); public static LinkedHashMap> getEntities() { return H.ENTITIES; diff --git a/common/src/main/resources/assets/betteranimalsplus/lang/en_us.json b/common/src/main/resources/assets/betteranimalsplus/lang/en_us.json index 88cdc3aa..15e5b6da 100644 --- a/common/src/main/resources/assets/betteranimalsplus/lang/en_us.json +++ b/common/src/main/resources/assets/betteranimalsplus/lang/en_us.json @@ -109,6 +109,7 @@ "entity.betteranimalsplus.octopus": "Octopus", "entity.betteranimalsplus.gazelle": "Gazelle", "entity.betteranimalsplus.crocodile": "Crocodile", + "entity.betteranimalsplus.alligator": "Alligator", "entity.betteranimalsplus.eel_saltwater.type.conger": "Conger", "entity.betteranimalsplus.eel_saltwater.type.dragon": "Dragon", diff --git a/common/src/main/resources/assets/betteranimalsplus/models/item/alligator_spawn_egg.json b/common/src/main/resources/assets/betteranimalsplus/models/item/alligator_spawn_egg.json new file mode 100644 index 00000000..7a2c6da8 --- /dev/null +++ b/common/src/main/resources/assets/betteranimalsplus/models/item/alligator_spawn_egg.json @@ -0,0 +1,3 @@ +{ + "parent": "item/template_spawn_egg" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/betteranimalsplus/textures/entity/alligator_albino.png b/common/src/main/resources/assets/betteranimalsplus/textures/entity/alligator_albino.png new file mode 100644 index 0000000000000000000000000000000000000000..8757cd61d5746ea3712451fb9fbd10dc0ceb9834 GIT binary patch literal 3126 zcmZveS5On`7KMYMhd^isLcmZBq7>=fAV|>AK_pZGDWV)gkuDI5G%^cSa2k4wA{_h1tTEmezxnYQ|zWxjr=yjk%|PahE#6ps!M=(>KXkhWhfy8P$}` zsbdigvNE$~{GSJqdmlwTZs71o+Xn&w+`WH3Q)`CrCIA3(F)>8hggS3Jqy|)L@eSxq zcm@W1_Y2r#EVR$-o)c$MLu6Go+WN&!xqByGf{k!&bwSttqN4l7hPKqWT8JOrgtWIT z=|^JrLXOD#BC$m7)A*OOpJVmDzXDjA$gE8#oRFi6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