file_name
stringlengths
6
86
file_path
stringlengths
45
249
content
stringlengths
47
6.26M
file_size
int64
47
6.26M
language
stringclasses
1 value
extension
stringclasses
1 value
repo_name
stringclasses
767 values
repo_stars
int64
8
14.4k
repo_forks
int64
0
1.17k
repo_open_issues
int64
0
788
repo_created_at
stringclasses
767 values
repo_pushed_at
stringclasses
767 values
ModelMonitor.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelMonitor.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.reptile.EntityMonitor; public class ModelMonitor extends AdvancedEntityModel<EntityMonitor> { private final AdvancedModelBox main_body; private final AdvancedModelBox head_neck; private final AdvancedModelBox arm_left; private final AdvancedModelBox leg_left; private final AdvancedModelBox tail_1; private final AdvancedModelBox arm_right; private final AdvancedModelBox leg_right; private final AdvancedModelBox head_face; private final AdvancedModelBox head_snout; private final AdvancedModelBox head_jaw; private final AdvancedModelBox head_tongue; private final AdvancedModelBox arm_left_2; private final AdvancedModelBox arm_left_hand; private final AdvancedModelBox leg_left_2; private final AdvancedModelBox leg_left_feet; private final AdvancedModelBox tail_2; private final AdvancedModelBox arm_right_2; private final AdvancedModelBox arm_right_hand; private final AdvancedModelBox leg_right_2; private final AdvancedModelBox leg_right_feet; private final ModelAnimator animator; public ModelMonitor() { this.texWidth = 64; this.texHeight = 32; this.main_body = new AdvancedModelBox(this, 0, 0); this.main_body.setRotationPoint(0.0F, 20.2F, 0.0F); this.main_body.addBox(-3.0F, -3.0F, -6.0F, 6, 5, 12, 0.0F); this.leg_right_2 = new AdvancedModelBox(this, 24, 6); this.leg_right_2.setRotationPoint(0.1F, 3.0F, 0.0F); this.leg_right_2.addBox(-1.0F, 0.0F, -1.5F, 2, 3, 3, 0.0F); this.setRotateAngle(leg_right_2, 0.40980330836826856F, 0.045553093477052F, -0.36425021489121656F); this.tail_1 = new AdvancedModelBox(this, 36, 0); this.tail_1.setRotationPoint(0.0F, -0.9F, 4.0F); this.tail_1.addBox(-1.5F, -2.0F, 0.0F, 3, 4, 10, 0.0F); this.setRotateAngle(tail_1, -0.31869712141416456F, 0.0F, 0.0F); this.head_face = new AdvancedModelBox(this, 18, 17); this.head_face.setRotationPoint(0.0F, -0.9F, -3.4F); this.head_face.addBox(-2.0F, -2.0F, -3.0F, 4, 4, 3, 0.0F); this.setRotateAngle(head_face, 0.22759093446006054F, 0.0F, 0.0F); this.head_snout = new AdvancedModelBox(this, 14, 24); this.head_snout.setRotationPoint(0.0F, -1.0F, -3.0F); this.head_snout.addBox(-1.5F, -1.0F, -4.0F, 3, 3, 4, 0.0F); this.leg_right = new AdvancedModelBox(this, 24, 0); this.leg_right.setRotationPoint(-3.0F, -1.9F, 4.8F); this.leg_right.addBox(-1.0F, 0.0F, -1.5F, 2, 4, 3, 0.0F); this.setRotateAngle(leg_right, -0.40980330836826856F, 0.045553093477052F, 0.36425021489121656F); this.leg_right_feet = new AdvancedModelBox(this, 33, 0); this.leg_right_feet.mirror = true; this.leg_right_feet.setRotationPoint(0.5F, 3.01F, -1.5F); this.leg_right_feet.addBox(-2.0F, 0.0F, -2.5F, 4, 0, 5, 0.0F); this.head_neck = new AdvancedModelBox(this, 0, 17); this.head_neck.setRotationPoint(0.0F, -0.30000000000000004F, -5.5F); this.head_neck.addBox(-2.5F, -2.5F, -4.0F, 5, 5, 4, 0.0F); this.setRotateAngle(head_neck, -0.22759093446006068F, 0.013037238685168382F, 0.0F); this.arm_left_hand = new AdvancedModelBox(this, 33, 0); this.arm_left_hand.setRotationPoint(-0.5F, 3.01F, -1.1F); this.arm_left_hand.addBox(-2.0F, 0.0F, -2.5F, 4, 0, 5, 0.0F); this.leg_left_feet = new AdvancedModelBox(this, 33, 0); this.leg_left_feet.setRotationPoint(-0.5F, 3.01F, -1.5F); this.leg_left_feet.addBox(-2.0F, 0.0F, -2.5F, 4, 0, 5, 0.0F); this.arm_right_2 = new AdvancedModelBox(this, 0, 6); this.arm_right_2.setRotationPoint(0.0F, 2.0F, 0.0F); this.arm_right_2.addBox(-1.0F, 0.0F, -1.5F, 2, 3, 3, 0.0F); this.setRotateAngle(arm_right_2, 0.0F, -0.045553093477052F, -0.5462880558742251F); this.leg_left_2 = new AdvancedModelBox(this, 24, 6); this.leg_left_2.mirror = true; this.leg_left_2.setRotationPoint(-0.1F, 3.0F, 0.0F); this.leg_left_2.addBox(-1.0F, 0.0F, -1.5F, 2, 3, 3, 0.0F); this.setRotateAngle(leg_left_2, 0.40980330836826856F, -0.045553093477052F, 0.36425021489121656F); this.arm_right_hand = new AdvancedModelBox(this, 33, 0); this.arm_right_hand.mirror = true; this.arm_right_hand.setRotationPoint(0.5F, 3.01F, -1.1F); this.arm_right_hand.addBox(-2.0F, 0.0F, -2.5F, 4, 0, 5, 0.0F); this.leg_left = new AdvancedModelBox(this, 24, 0); this.leg_left.mirror = true; this.leg_left.setRotationPoint(3.0F, -1.9F, 4.8F); this.leg_left.addBox(-1.0F, 0.0F, -1.5F, 2, 4, 3, 0.0F); this.setRotateAngle(leg_left, -0.40980330836826867F, -0.045553093477052F, -0.3642502148912164F); this.tail_2 = new AdvancedModelBox(this, 40, 14); this.tail_2.setRotationPoint(0.0F, 0.5F, 9.0F); this.tail_2.addBox(-1.0F, -1.5F, 0.0F, 2, 3, 10, 0.0F); this.setRotateAngle(tail_2, 0.22759093446006054F, 0.0F, 0.0F); this.arm_left_2 = new AdvancedModelBox(this, 0, 6); this.arm_left_2.mirror = true; this.arm_left_2.setRotationPoint(0.0F, 2.0F, 0.0F); this.arm_left_2.addBox(-1.0F, 0.0F, -1.5F, 2, 3, 3, 0.0F); this.setRotateAngle(arm_left_2, 0.0F, 0.04555309347705199F, 0.5462880558742251F); this.arm_left = new AdvancedModelBox(this, 0, 0); this.arm_left.mirror = true; this.arm_left.setRotationPoint(2.8F, -1.0F, -5.2F); this.arm_left.addBox(-1.0F, 0.0F, -1.5F, 2, 2, 3, 0.0F); this.setRotateAngle(arm_left, 0.0F, 0.045553093477052F, -0.5462880558742247F); this.head_jaw = new AdvancedModelBox(this, 0, 26); this.head_jaw.setRotationPoint(0.0F, 1.0F, -3.0F); this.head_jaw.addBox(-1.5F, 0.0F, -4.0F, 3, 1, 4, 0.0F); this.head_tongue = new AdvancedModelBox(this, 22, 26); this.head_tongue.setRotationPoint(0.0F, -0.01F, 0.0F); this.head_tongue.addBox(-1.5F, 0.0F, -4.0F, 3, 0, 6, 0.0F); this.arm_right = new AdvancedModelBox(this, 0, 0); this.arm_right.setRotationPoint(-2.8F, -1.0F, -5.2F); this.arm_right.addBox(-1.0F, 0.0F, -1.5F, 2, 2, 3, 0.0F); this.setRotateAngle(arm_right, 0.0F, -0.045553093477052F, 0.5462880558742251F); this.leg_right.addChild(this.leg_right_2); this.main_body.addChild(this.tail_1); this.head_neck.addChild(this.head_face); this.head_face.addChild(this.head_snout); this.main_body.addChild(this.leg_right); this.leg_right_2.addChild(this.leg_right_feet); this.main_body.addChild(this.head_neck); this.arm_left_2.addChild(this.arm_left_hand); this.leg_left_2.addChild(this.leg_left_feet); this.arm_right.addChild(this.arm_right_2); this.leg_left.addChild(this.leg_left_2); this.arm_right_2.addChild(this.arm_right_hand); this.main_body.addChild(this.leg_left); this.tail_1.addChild(this.tail_2); this.arm_left.addChild(this.arm_left_2); this.main_body.addChild(this.arm_left); this.head_face.addChild(this.head_jaw); this.head_jaw.addChild(this.head_tongue); this.main_body.addChild(this.arm_right); animator = ModelAnimator.create(); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(main_body); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of(main_body, head_neck, arm_left, leg_left, tail_1, arm_right, leg_right, head_face, head_snout, head_jaw, head_tongue, arm_left_2, arm_left_hand, leg_left_2, leg_left_feet, tail_2, arm_right_2, arm_right_hand, leg_right_2, leg_right_feet ); } private void animate(IAnimatedEntity entityIn) { EntityMonitor monitor = (EntityMonitor) entityIn; animator.update(monitor); animator.setAnimation(EntityMonitor.ATTACK_THRASH); int invert = 1; for (int i = 0; i < 4; i++) { animator.startKeyframe(6); this.rotate(animator, head_neck, 0, 22.73F * invert , 0); this.rotate(animator, head_face, -5.21F, 15.65F * invert, 31.30F * invert); this.rotate(animator, head_jaw, 20.87F, 0, 0); invert = invert * -1; animator.endKeyframe(); } animator.resetKeyframe(6); animator.setAnimation(EntityMonitor.IDLE_TONGUE); animator.startKeyframe(4); this.rotate(animator, head_tongue, 26.08F, 36.52F, 0); animator.move(head_tongue, 0, 0, -4F); animator.endKeyframe(); animator.startKeyframe(3); this.rotate(animator, head_tongue, -26.08F, -36.52F, 0); animator.move(head_tongue, 0, 0, -5F); animator.endKeyframe(); animator.startKeyframe(3); animator.endKeyframe(); animator.resetKeyframe(10); } public void setupAnim(EntityMonitor monitor, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { resetToDefaultPose(); animate(monitor); float globalSpeed = 0.8f; float globalDegree = 1.0f; limbSwingAmount = Math.min(0.6F, limbSwingAmount); if (monitor.isNoAi()) { limbSwing = ageInTicks / 4; limbSwingAmount = 0.5F; } // Breathing Animation this.main_body.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.head_neck.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.head_face.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.tail_1.setScale(1F, (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); //this.head_jaw.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); //this.head_snout.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); // Head Tracking Animation if (!monitor.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 2, head_face); } // Pitch/Yaw handler if (monitor.isInWater() && !monitor.isOnGround()) { this.setRotateAngle(main_body, monitor.getXRot() * ((float) Math.PI / 180F), 0, 0); } this.main_body.rotateAngleY = Mth.rotLerp((float) 0.05, this.main_body.rotateAngleY, monitor.offset); this.tail_1.rotateAngleY = Mth.rotLerp((float) 0.05, this.tail_1.rotateAngleY, -1F * monitor.offset); this.tail_2.rotateAngleY = Mth.rotLerp((float) 0.05, this.tail_2.rotateAngleY, -2F * monitor.offset); // Movement Animation AdvancedModelBox[] bodyParts = new AdvancedModelBox[]{head_face, head_neck, main_body, tail_1, tail_2}; chainSwing(bodyParts, globalSpeed * 1.4F, globalDegree * 1.2F, -4, limbSwing, limbSwingAmount * 0.3F); if (monitor.isInWater()) { flap(arm_left, globalSpeed, globalDegree, false, 0.8F, 1f, limbSwing, limbSwingAmount); flap(leg_left, globalSpeed, globalDegree * 0.8f, false, 1.6F, 1f, limbSwing, limbSwingAmount); flap(arm_right, globalSpeed, globalDegree, false, 2.4F, 1f, limbSwing, limbSwingAmount); flap(leg_right, globalSpeed, globalDegree * 0.8f, false, 3.2F, 1f, limbSwing, limbSwingAmount); flap(main_body, globalSpeed / 2, globalDegree * 1.2f, false, 0, 0.1f, limbSwing / 2, limbSwingAmount); swing(main_body, globalSpeed / 2, globalDegree * 1.2f, false, 0.8F, 0.1f, limbSwing / 3, limbSwingAmount); chainWave(new AdvancedModelBox[]{head_face, head_neck, main_body}, globalSpeed * 0.8F, globalDegree, -4, limbSwing, limbSwingAmount * 0.2F); } else { walk(arm_left, globalSpeed, globalDegree * 2F, false, -1, 0f, limbSwing, limbSwingAmount); flap(arm_left, globalSpeed, globalDegree * 1, false, 1, -1.5f, limbSwing, limbSwingAmount); flap(arm_left_2, globalSpeed, globalDegree * 1f, true, -1, 0f, limbSwing, limbSwingAmount); walk(arm_right, globalSpeed, globalDegree * 2F, true, 0, 0f, limbSwing, limbSwingAmount); flap(arm_right, globalSpeed, globalDegree * 1, false, 2, 1.5f, limbSwing, limbSwingAmount); flap(arm_right_2, globalSpeed, globalDegree * 1f, true, 0, 0f, limbSwing, limbSwingAmount); walk(leg_left, globalSpeed, globalDegree * 2F, false, 1, 0f, limbSwing, limbSwingAmount); flap(leg_left, globalSpeed, globalDegree * 1, false, 3, 0.5f, limbSwing, limbSwingAmount); flap(leg_left_2, globalSpeed, globalDegree * 1f, true, 1, 0f, limbSwing, limbSwingAmount); walk(leg_right, globalSpeed, globalDegree * 2F, true, 2, 0f, limbSwing, limbSwingAmount); flap(leg_right, globalSpeed, globalDegree * 1, false, 4, 0.5f, limbSwing, limbSwingAmount); flap(leg_right_2, globalSpeed, globalDegree * 1f, true, 2, 0f, limbSwing, limbSwingAmount); } if (monitor.getTarget() == null && monitor.getAnimation() != EntityMonitor.ATTACK_THRASH) { this.setRotateAngle(head_neck, head_neck.rotateAngleX, monitor.head_movement.getA(), 0.0F); this.setRotateAngle(head_face, head_face.rotateAngleX, monitor.head_movement.getB(), 0.0F); } // Swimming Animation if (monitor.swimProgress > 0) { this.progressPosition(arm_left, monitor.swimProgress, 2.8F, 1F, -5.2F, 20); this.progressRotation(arm_left, monitor.swimProgress, (float) Math.toRadians(93.91F), (float) Math.toRadians(18.26F), (float) Math.toRadians(-15.65F), 20); this.progressPosition(arm_left_hand, monitor.swimProgress, 1.1F, 3.01F, -0.5F, 20); this.progressRotation(arm_left_hand, monitor.swimProgress, 0, (float) Math.toRadians(-88.7F), (float) Math.toRadians(86.09F), 20); this.progressPosition(leg_left, monitor.swimProgress, 3F, 0.1F, 4.8F, 20); this.progressRotation(leg_left, monitor.swimProgress, (float) Math.toRadians(83.48F), (float) Math.toRadians(-2.61F), (float) Math.toRadians(-20.87F), 20); this.progressRotation(tail_1, monitor.swimProgress, 0, 0, 0, 20); this.progressRotation(tail_2, monitor.swimProgress, 0, 0, 0, 20); this.progressPosition(arm_right, monitor.swimProgress, -2.8F, 1F, -5.2F, 20); this.progressRotation(arm_right, monitor.swimProgress, (float) Math.toRadians(93.91F), (float) Math.toRadians(-18.26F), (float) Math.toRadians(15.65F), 20); this.progressPosition(arm_right_hand, monitor.swimProgress, -1.1F, 3.01F, -0.5F, 20); this.progressRotation(arm_right_hand, monitor.swimProgress, 0, (float) Math.toRadians(88.7F), (float) Math.toRadians(-86.09F), 20); this.progressPosition(leg_right, monitor.swimProgress, -3F, 0.1F, 4.8F, 20); this.progressRotation(leg_right, monitor.swimProgress, (float) Math.toRadians(83.48F), (float) Math.toRadians(2.61F), (float) Math.toRadians(20.87F), 20); } // Sitting Animation if (monitor.sitProgress != 0) { this.progressPosition(head_neck, monitor.sitProgress, 0, -1.3F, -5.5F, monitor.ticksToSit); this.progressRotation(head_neck, monitor.sitProgress, (float) Math.toRadians(-54.78F), (float) Math.toRadians(0.75F), 0, monitor.ticksToSit); this.progressRotation(head_face, monitor.sitProgress, (float) Math.toRadians(54.78F), 0, 0, monitor.ticksToSit); this.progressPosition(main_body, monitor.sitProgress, 0, 22.4F, 0, monitor.ticksToSit); this.progressRotation(arm_left, monitor.sitProgress, (float) Math.toRadians(-31.30F), (float) Math.toRadians(2.61F), (float) Math.toRadians(-54.78F), monitor.ticksToSit); this.progressRotation(arm_left_2, monitor.sitProgress, (float) Math.toRadians(-5.22F), (float) Math.toRadians(-5.22F), (float) Math.toRadians(7.83F), monitor.ticksToSit); this.progressPosition(arm_left_hand, monitor.sitProgress, -0.5F, 2.51F, -1.1F, monitor.ticksToSit); this.progressRotation(arm_left_hand, monitor.sitProgress, (float) Math.toRadians(20.87F), (float) Math.toRadians(-20.87F), (float) Math.toRadians(31.30F), monitor.ticksToSit); this.progressRotation(arm_right, monitor.sitProgress, (float) Math.toRadians(-31.30F), (float) Math.toRadians(-2.61F), (float) Math.toRadians(54.78F), monitor.ticksToSit); this.progressRotation(arm_right_2, monitor.sitProgress, (float) Math.toRadians(-5.22F), (float) Math.toRadians(5.22F), (float) Math.toRadians(-7.83F), monitor.ticksToSit); this.progressRotation(arm_right_hand, monitor.sitProgress, (float) Math.toRadians(20.87F), (float) Math.toRadians(20.87F), (float) Math.toRadians(-31.30F), monitor.ticksToSit); this.progressPosition(arm_right_hand, monitor.sitProgress, 0.5F, 2.51F, -1.1F, monitor.ticksToSit); this.progressPosition(leg_left, monitor.sitProgress, 3F, -0.9F, 4.8F, monitor.ticksToSit); this.progressRotation(leg_left, monitor.sitProgress, (float) Math.toRadians(49.57F), (float) Math.toRadians(-2.61F), (float) Math.toRadians(-75.65F), monitor.ticksToSit); this.progressPosition(leg_left_feet, monitor.sitProgress, 0.5F, 3.01F, -1.5F, monitor.ticksToSit); this.progressRotation(leg_left_feet, monitor.sitProgress, (float) Math.toRadians(-31.30F), (float) Math.toRadians(-36.52F), (float) Math.toRadians(88.70F), monitor.ticksToSit); this.progressPosition(leg_right, monitor.sitProgress, -3F, -0.9F, 4.8F, monitor.ticksToSit); this.progressRotation(leg_right, monitor.sitProgress, (float) Math.toRadians(49.57F), (float) Math.toRadians(2.61F), (float) Math.toRadians(75.65F), monitor.ticksToSit); this.progressPosition(leg_right_feet, monitor.sitProgress, -0.5F, 3.01F, -1.5F, monitor.ticksToSit); this.progressRotation(leg_right_feet, monitor.sitProgress, (float) Math.toRadians(-31.30F), (float) Math.toRadians(36.52F), (float) Math.toRadians(-88.70F), monitor.ticksToSit); this.progressRotation(tail_1, monitor.sitProgress, (float) Math.toRadians(-2.61F), tail_1.rotateAngleY, 0, monitor.ticksToSit); this.progressRotation(tail_2, monitor.sitProgress, 0, tail_2.rotateAngleY, 0, monitor.ticksToSit); } } }
19,163
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelBison.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelBison.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityBison; public class ModelBison extends AdvancedEntityModel<EntityBison> { private final AdvancedModelBox body_main; private final AdvancedModelBox body_torso; private final AdvancedModelBox leg_left_thigh; private final AdvancedModelBox leg_right_thigh; private final AdvancedModelBox body_hair; private final AdvancedModelBox tail; private final AdvancedModelBox arm_right_1; private final AdvancedModelBox arm_left_1; private final AdvancedModelBox head_neck; private final AdvancedModelBox arm_right_2; private final AdvancedModelBox arm_right_fur; private final AdvancedModelBox arm_left_2; private final AdvancedModelBox arm_left_fur; private final AdvancedModelBox head_main; private final AdvancedModelBox head_hair; private final AdvancedModelBox head_horn_right; private final AdvancedModelBox head_ear_right; private final AdvancedModelBox head_ear_left; private final AdvancedModelBox head_horn_left; private final AdvancedModelBox head_beard; private final AdvancedModelBox eye_left; private final AdvancedModelBox eye_right; private final AdvancedModelBox leg_left_calf; private final AdvancedModelBox leg_right_calf; private final ModelAnimator animator; public ModelBison() { this.texWidth = 128; this.texHeight = 64; this.body_torso = new AdvancedModelBox(this, 64, 0); this.body_torso.setRotationPoint(0.0F, 0.0F, -8.0F); this.body_torso.addBox(-6.0F, -7.0F, -6.0F, 12, 14, 12, 0.0F); this.setRotateAngle(body_torso, 0.31869712141416456F, 0.0F, 0.0F); this.arm_left_1 = new AdvancedModelBox(this, 0, 0); this.arm_left_1.setRotationPoint(4.5F, 2.2F, -2.0F); this.arm_left_1.addBox(-2.0F, 0.0F, -2.0F, 4, 7, 4, 0.0F); this.setRotateAngle(arm_left_1, -0.18203784098300857F, 0.0F, 0.0F); this.arm_left_2 = new AdvancedModelBox(this, 0, 12); this.arm_left_2.setRotationPoint(0.0F, 6.3F, 0.0F); this.arm_left_2.addBox(-1.5F, 0.0F, -1.5F, 3, 5, 3, 0.0F); this.setRotateAngle(arm_left_2, -0.136659280431156F, 0.0F, 0.0F); this.arm_right_2 = new AdvancedModelBox(this, 0, 12); this.arm_right_2.mirror = true; this.arm_right_2.setRotationPoint(0.0F, 6.3F, 0.0F); this.arm_right_2.addBox(-1.5F, 0.0F, -1.5F, 3, 5, 3, 0.0F); this.setRotateAngle(arm_right_2, -0.136659280431156F, 0.0F, 0.0F); this.head_horn_right = new AdvancedModelBox(this, 0, 47); this.head_horn_right.mirror = true; this.head_horn_right.setRotationPoint(-2.0F, -3.0F, -2.5F); this.head_horn_right.addBox(-4.0F, -1.0F, 0.0F, 4, 2, 2, 0.0F); this.setRotateAngle(head_horn_right, 0.18203784098300857F, -0.18203784098300857F, 0.36425021489121656F); this.leg_left_calf = new AdvancedModelBox(this, 86, 26); this.leg_left_calf.setRotationPoint(0.7F, 3.5F, 2.5F); this.leg_left_calf.addBox(-1.0F, 0.0F, -1.0F, 3, 10, 3, 0.0F); this.head_horn_left = new AdvancedModelBox(this, 0, 47); this.head_horn_left.setRotationPoint(2.0F, -3.0F, -2.5F); this.head_horn_left.addBox(0.0F, -1.0F, 0.0F, 4, 2, 2, 0.0F); this.setRotateAngle(head_horn_left, 0.18203784098300857F, 0.18203784098300857F, -0.36425021489121656F); this.head_beard = new AdvancedModelBox(this, 22, 44); this.head_beard.setRotationPoint(0.0F, 3.0F, -0.5F); this.head_beard.addBox(-2.0F, 0.0F, -1.5F, 4, 5, 3, 0.0F); this.setRotateAngle(head_beard, 0.18203784098300857F, 0.0F, 0.0F); this.body_hair = new AdvancedModelBox(this, 0, 36); this.body_hair.setRotationPoint(0.0F, 5.3F, -0.4F); this.body_hair.addBox(0.0F, 0.0F, -12.0F, 0, 4, 24, 0.0F); this.setRotateAngle(body_hair, 0.091106186954104F, 0.0F, 0.0F); this.eye_right = new AdvancedModelBox(this, 0, 30); this.eye_right.setRotationPoint(-2.51F, 0.0F, -2.0F); this.eye_right.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.body_main = new AdvancedModelBox(this, 0, 0); this.body_main.setRotationPoint(0.0F, 10.0F, 6.0F); this.body_main.addBox(-5.5F, -6.0F, -10.0F, 11, 12, 20, 0.0F); this.leg_right_thigh = new AdvancedModelBox(this, 62, 26); this.leg_right_thigh.mirror = true; this.leg_right_thigh.setRotationPoint(-4.0F, 0.5F, 7.5F); this.leg_right_thigh.addBox(-3.0F, -3.5F, -3.5F, 5, 10, 7, 0.0F); this.head_neck = new AdvancedModelBox(this, 8, 47); this.head_neck.setRotationPoint(0.0F, -1.0F, -3.5F); this.head_neck.addBox(-2.0F, -3.5F, -6.0F, 4, 7, 6, 0.0F); this.setRotateAngle(head_neck, -0.22759093446006054F, 0.0F, 0.0F); this.leg_right_calf = new AdvancedModelBox(this, 86, 26); this.leg_right_calf.mirror = true; this.leg_right_calf.setRotationPoint(-0.7F, 3.5F, 2.5F); this.leg_right_calf.addBox(-2.0F, 0.0F, -1.0F, 3, 10, 3, 0.0F); this.head_ear_right = new AdvancedModelBox(this, 18, 32); this.head_ear_right.setRotationPoint(-3.5F, -1.3F, -0.4F); this.head_ear_right.addBox(-2.0F, -1.0F, 0.0F, 3, 2, 1, 0.0F); this.setRotateAngle(head_ear_right, 0.18203784098300857F, 0.18203784098300857F, -0.136659280431156F); this.head_main = new AdvancedModelBox(this, 0, 32); this.head_main.setRotationPoint(0.0F, 2.0F, -5.0F); this.head_main.addBox(-2.5F, -4.5F, -5.0F, 5, 9, 6, 0.0F); this.setRotateAngle(head_main, -0.36425021489121656F, 0.0F, 0.0F); this.head_hair = new AdvancedModelBox(this, 22, 32); this.head_hair.setRotationPoint(0.0F, -2.4F, -2.4F); this.head_hair.addBox(-3.0F, -3.0F, -3.0F, 6, 4, 7, 0.0F); this.setRotateAngle(head_hair, 0.22759093446006054F, 0.0F, 0.0F); this.arm_right_1 = new AdvancedModelBox(this, 0, 0); this.arm_right_1.mirror = true; this.arm_right_1.setRotationPoint(-4.5F, 2.2F, -2.0F); this.arm_right_1.addBox(-2.0F, 0.0F, -2.0F, 4, 7, 4, 0.0F); this.setRotateAngle(arm_right_1, -0.18203784098300857F, 0.0F, 0.0F); this.arm_left_fur = new AdvancedModelBox(this, 42, 0); this.arm_left_fur.setRotationPoint(0.0F, 0.0F, 0.0F); this.arm_left_fur.addBox(-2.5F, -0.1F, -3.0F, 5, 9, 6, 0.0F); this.leg_left_thigh = new AdvancedModelBox(this, 62, 26); this.leg_left_thigh.setRotationPoint(4.0F, 0.5F, 7.5F); this.leg_left_thigh.addBox(-2.0F, -3.5F, -3.5F, 5, 10, 7, 0.0F); this.tail = new AdvancedModelBox(this, 64, 0); this.tail.setRotationPoint(0.0F, -6.0F, 10.0F); this.tail.addBox(-2.5F, 0.0F, 0.0F, 5, 10, 0, 0.0F); this.setRotateAngle(tail, 0.18203784098300857F, 0.0F, 0.0F); this.head_ear_left = new AdvancedModelBox(this, 18, 32); this.head_ear_left.mirror = true; this.head_ear_left.setRotationPoint(3.5F, -1.3F, -0.4F); this.head_ear_left.addBox(-1.0F, -1.0F, 0.0F, 3, 2, 1, 0.0F); this.setRotateAngle(head_ear_left, 0.18203784098300857F, -0.18203784098300857F, 0.136659280431156F); this.eye_left = new AdvancedModelBox(this, 0, 30); this.eye_left.setRotationPoint(2.51F, 0.0F, -2.0F); this.eye_left.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.arm_right_fur = new AdvancedModelBox(this, 42, 0); this.arm_right_fur.mirror = true; this.arm_right_fur.setRotationPoint(0.0F, 0.0F, 0.0F); this.arm_right_fur.addBox(-2.5F, -0.1F, -3.0F, 5, 9, 6, 0.0F); this.body_main.addChild(this.body_torso); this.body_torso.addChild(this.arm_left_1); this.arm_left_1.addChild(this.arm_left_2); this.arm_right_1.addChild(this.arm_right_2); this.head_main.addChild(this.head_horn_right); this.leg_left_thigh.addChild(this.leg_left_calf); this.head_main.addChild(this.head_horn_left); this.head_main.addChild(this.head_beard); this.body_main.addChild(this.body_hair); this.head_main.addChild(this.eye_right); this.body_main.addChild(this.leg_right_thigh); this.body_torso.addChild(this.head_neck); this.leg_right_thigh.addChild(this.leg_right_calf); this.head_main.addChild(this.head_ear_right); this.head_neck.addChild(this.head_main); this.head_main.addChild(this.head_hair); this.body_torso.addChild(this.arm_right_1); this.arm_left_1.addChild(this.arm_left_fur); this.body_main.addChild(this.leg_left_thigh); this.body_main.addChild(this.tail); this.head_main.addChild(this.head_ear_left); this.head_main.addChild(this.eye_left); this.arm_right_1.addChild(this.arm_right_fur); animator = ModelAnimator.create(); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( body_main, body_torso, leg_left_thigh, leg_right_thigh, body_hair, tail, arm_right_1, arm_left_1, head_neck, arm_right_2, arm_right_fur, arm_left_2, arm_left_fur, head_main, head_hair, head_horn_right, head_ear_right, head_ear_left, head_horn_left, head_beard, eye_left, eye_right, leg_left_calf, leg_right_calf ); } private void animate(IAnimatedEntity entityIn) { EntityBison bison = (EntityBison) entityIn; animator.update(bison); animator.setAnimation(EntityBison.ATTACK_THREATEN); for (int i = 0; i < 2; i++) { animator.startKeyframe(12); this.rotate(animator, body_torso, 0, 0, 7.83F); this.rotate(animator, head_neck, 7.83F, 0, -13.04F); this.rotate(animator, arm_right_2, 31.31F, 0, 0); animator.move(arm_left_1, 0, -0.6F, 0); this.rotate(animator, arm_left_1, 0, 0, -7.83F); animator.move(arm_right_1, 0, -0.5F, 0); this.rotate(animator, arm_right_1, -46.96F, 0, -5.21F); animator.endKeyframe(); animator.startKeyframe(9); this.rotate(animator, body_torso, 0, 0, -13.05F); this.rotate(animator, head_neck, 7.83F, 0, 26.08F); this.rotate(animator, arm_right_2, 31.31F, 0, 0); animator.move(arm_left_1, 0, 0.5F, 0); this.rotate(animator, arm_left_1, 0, 0, 13.04F); animator.move(arm_right_1, 0, 0.5F, 0); this.rotate(animator, arm_right_1, 54.79F, 0, 10.43F); animator.endKeyframe(); } animator.resetKeyframe(8); animator.setAnimation(EntityBison.ATTACK_GORE); animator.startKeyframe(6); this.rotate(animator, head_neck, 31.31F, 0, 26.08F); animator.endKeyframe(); animator.startKeyframe(4); this.rotate(animator, head_neck, -26.08F, 0, -46.96F); animator.endKeyframe(); animator.resetKeyframe(4); } public void setupAnim(EntityBison bison, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); animate(bison); float globalSpeed = 1.5f; float globalDegree = 1f; float f = limbSwing / 2; limbSwingAmount = Math.min(0.4F, limbSwingAmount); // Breathing Animation this.body_main.setScale((float) (1.0F + Math.sin(ageInTicks / 20) * 0.08F), (float) (1.0F + Math.sin(ageInTicks / 16) * 0.08F), 1.0F); this.body_torso.setScale((float) (1.0F + Math.sin(ageInTicks / 20) * 0.08F), (float) (1.0F + Math.sin(ageInTicks / 16) * 0.08F), 1.0F); bob(body_main, 0.4F * globalSpeed, 0.1F, false, ageInTicks / 20, 2); bob(arm_right_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(arm_left_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_right_thigh, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_left_thigh, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); walk(head_neck, 0.4f * globalSpeed, 0.03f, false, 2.8F, 0.06F, ageInTicks / 20, 2); // Blinking Animation if (!bison.shouldRenderEyes()) { this.eye_right.setRotationPoint(-2F, -2.0F, -4.0F); this.eye_left.setRotationPoint(2F, -2.0F, -4.0F); } // Head Tracking Animation if (!bison.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 3, head_neck); this.faceTarget(netHeadYaw, headPitch, 3, head_main); } // Pitch/Yaw handler if (bison.isInWater()) { this.setRotateAngle(head_main, -0.18203784098300857F, 0.0F, 0.0F); if (!bison.isOnGround()) { f = ageInTicks / 6; limbSwingAmount = 0.5f; float pitch = Mth.clamp(bison.getXRot() - 10, -25F, 25.0F); this.setRotateAngle(body_main, (float) (pitch * Math.PI / 180F), 0, 0); } } // Movement Animation if (bison.canMove()) { bob(body_main, 0.8f * globalSpeed, 0.6f * globalDegree, true, f, limbSwingAmount); walk(head_neck, 0.8f * globalSpeed, 0.2f * globalDegree, false, 0, 0, f, limbSwingAmount); walk(head_main, 0.8f * globalSpeed, 0.15f * globalDegree, true, 0, 0, f, limbSwingAmount); walk(arm_right_1, -0.8f * globalSpeed, 1.4f * globalDegree, true, 0F, 1.4f, f, limbSwingAmount); walk(arm_right_2, -0.8f * globalSpeed, 1.4f * globalDegree, false, -1F, 1.4f, f, limbSwingAmount * 1.2f); walk(arm_left_1, -0.8f * globalSpeed, 1.4f * globalDegree, true, 2F, 1.4f, f, limbSwingAmount); walk(arm_left_2, -0.8f * globalSpeed, 1.4f * globalDegree, false, 1F, 1.4f, f, limbSwingAmount * 1.2f); walk(leg_right_thigh, 0.8f * globalSpeed, 1.4f * globalDegree, false, 2.8F, 0, f, limbSwingAmount); walk(leg_right_calf, 0.8f * globalSpeed, 1.4f * globalDegree, true, 1.8F, 0, f, limbSwingAmount); walk(leg_left_thigh, 0.8f * globalSpeed, 1.4f * globalDegree, false, 0.8F, 0, f, limbSwingAmount); walk(leg_left_calf, 0.8f * globalSpeed, 1.4f * globalDegree, true, -0.2F, 0, f, limbSwingAmount); } // Sitting Animation if (bison.sitProgress > 0) { this.progressPosition(body_main, bison.sitProgress, 0.0F, 17.5F, 0.0F, 40); this.progressRotation(head_neck, bison.sitProgress, (float) Math.toRadians(-33.91F), 0, 0, 40); this.progressRotation(head_main, bison.sitProgress, (float) Math.toRadians(-2.61F), 0, 0, 40); this.progressPosition(arm_right_1, bison.sitProgress, -4.5F, 0.2F, -2.0F, 40); this.progressRotation(arm_right_1, bison.sitProgress, (float) Math.toRadians(-65.22F), 0, 0, 40); this.progressRotation(arm_right_2, bison.sitProgress, (float) Math.toRadians(135.65F), 0.0F, (float) Math.toRadians(-15.65F), 40); this.progressPosition(arm_left_1, bison.sitProgress, 4.5F, 0.2F, -2.0F, 40); this.progressRotation(arm_left_1, bison.sitProgress, (float) Math.toRadians(-65.22F), 0, 0, 40); this.progressRotation(arm_left_2, bison.sitProgress, (float) Math.toRadians(135.65F), 0.0F, (float) Math.toRadians(15.65F), 40); this.progressRotation(leg_right_thigh, bison.sitProgress, (float) Math.toRadians(-73.04F), (float) Math.toRadians(15.65F), 0, 40); this.progressRotation(leg_right_calf, bison.sitProgress, (float) Math.toRadians(-10.43F), 0.0F, (float) Math.toRadians(-10.43F), 40); this.progressRotation(leg_left_thigh, bison.sitProgress, (float) Math.toRadians(-73.04F), (float) Math.toRadians(-15.65F), 0, 40); this.progressRotation(leg_left_calf, bison.sitProgress, (float) Math.toRadians(-10.43F), 0.0F, (float) Math.toRadians(10.43F), 40); } // Sleeping Animation else if (bison.sleepProgress > 0) { this.progressPosition(body_main, bison.sleepProgress, 0.0F, 17.5F, 0.0F, 40); this.progressPosition(arm_right_1, bison.sleepProgress, -4.5F, 0.2F, -2.0F, 40); this.progressRotation(arm_right_1, bison.sleepProgress, (float) Math.toRadians(-65.22F), 0, 0, 40); this.progressRotation(arm_right_2, bison.sleepProgress, (float) Math.toRadians(135.65F), 0.0F, (float) Math.toRadians(-15.65F), 40); this.progressPosition(arm_left_1, bison.sleepProgress, 4.5F, 0.2F, -2.0F, 40); this.progressRotation(arm_left_1, bison.sleepProgress, (float) Math.toRadians(-65.22F), 0, 0, 40); this.progressRotation(arm_left_2, bison.sleepProgress, (float) Math.toRadians(135.65F), 0.0F, (float) Math.toRadians(15.65F), 40); this.progressRotation(leg_right_thigh, bison.sleepProgress, (float) Math.toRadians(-73.04F), (float) Math.toRadians(15.65F), 0, 40); this.progressRotation(leg_right_calf, bison.sleepProgress, (float) Math.toRadians(-10.43F), 0.0F, (float) Math.toRadians(-10.43F), 40); this.progressRotation(leg_left_thigh, bison.sleepProgress, (float) Math.toRadians(-73.04F), (float) Math.toRadians(-15.65F), 0, 40); this.progressRotation(leg_left_calf, bison.sleepProgress, (float) Math.toRadians(-10.43F), 0.0F, (float) Math.toRadians(10.43F), 40); } } }
18,217
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelBaleenWhale.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelBaleenWhale.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityBaleenWhale; public class ModelBaleenWhale extends AdvancedEntityModel<EntityBaleenWhale> { private final AdvancedModelBox main_body; private final AdvancedModelBox main_head; private final AdvancedModelBox fin_left; private final AdvancedModelBox tail_1; private final AdvancedModelBox fin_right; private final AdvancedModelBox head_mouth_top; private final AdvancedModelBox head_jaw_1; private final AdvancedModelBox head_mouth_top_1; private final AdvancedModelBox head_jaw_2; private final AdvancedModelBox fin_dorsal; private final AdvancedModelBox tail_2; private final AdvancedModelBox tail_3; private final AdvancedModelBox tail_left; private final AdvancedModelBox tail_right; private static AdvancedModelBox[] bodyParts; public ModelBaleenWhale() { this.texWidth = 256; this.texHeight = 256; this.tail_3 = new AdvancedModelBox(this, 0, 16); this.tail_3.setRotationPoint(0.0F, 0.0F, 30.0F); this.tail_3.addBox(-6.0F, -6.0F, 0.0F, 12, 12, 10, 0.0F); this.head_mouth_top_1 = new AdvancedModelBox(this, 160, 72); this.head_mouth_top_1.setRotationPoint(0.0F, 6.0F, 0.0F); this.head_mouth_top_1.addBox(-9.0F, 0.0F, -26.0F, 18, 8, 26, 0.0F); this.main_head = new AdvancedModelBox(this, 92, 0); this.main_head.setRotationPoint(0.0F, -4.0F, 0.0F); this.main_head.addBox(-12.0F, -6.0F, -10.0F, 24, 12, 12, 0.0F); this.setRotateAngle(main_head, 0.045553093477052F, 0.0F, 0.0F); this.main_head.scaleX = 1.02F; this.tail_1 = new AdvancedModelBox(this, 136, 16); this.tail_1.setRotationPoint(0.0F, 0.0F, 38.0F); this.tail_1.addBox(-10.0F, -9.0F, 0.0F, 20, 18, 38, 0.0F); this.main_body = new AdvancedModelBox(this, 0, 0); this.main_body.setRotationPoint(0.0F, 12.0F, -32.0F); this.main_body.addBox(-12.0F, -10.0F, 0.0F, 24, 22, 44, 0.0F); this.tail_right = new AdvancedModelBox(this, 0, 162); this.tail_right.mirror = true; this.tail_right.setRotationPoint(-1.0F, 0.0F, 7.0F); this.tail_right.addBox(-30.0F, -2.0F, -8.0F, 30, 4, 14, 0.0F); this.setRotateAngle(tail_right, 0.0F, 0.5918411493512771F, 0.0F); this.head_jaw_1 = new AdvancedModelBox(this, 68, 72); this.head_jaw_1.setRotationPoint(0.0F, 2.0F, 0.0F); this.head_jaw_1.addBox(-12.0F, 4.0F, -42.0F, 24, 8, 44, 0.0F); this.setRotateAngle(head_jaw_1, -0.136659280431156F, 0.0F, 0.0F); this.head_jaw_1.scaleX = 1.01F; this.fin_right = new AdvancedModelBox(this, 164, 0); this.fin_right.mirror = true; this.fin_right.setRotationPoint(-7.0F, 5.0F, 11.0F); this.fin_right.addBox(-28.0F, -2.0F, -6.0F, 28, 4, 12, 0.0F); this.setRotateAngle(fin_right, 0.0F, 0.5918411493512771F, -0.6829473363053812F); this.head_jaw_2 = new AdvancedModelBox(this, 0, 124); this.head_jaw_2.setRotationPoint(0.0F, 4.0F, -10.0F); this.head_jaw_2.addBox(-12.0F, -6.0F, -32.0F, 24, 6, 32, 0.0F); this.tail_2 = new AdvancedModelBox(this, 114, 124); this.tail_2.setRotationPoint(0.0F, 0.0F, 38.0F); this.tail_2.addBox(-6.0F, -7.0F, 0.0F, 12, 14, 30, 0.0F); this.tail_left = new AdvancedModelBox(this, 0, 162); this.tail_left.setRotationPoint(1.0F, 0.0F, 7.0F); this.tail_left.addBox(0.0F, -2.0F, -8.0F, 30, 4, 14, 0.0F); this.setRotateAngle(tail_left, 0.0F, -0.5918411493512771F, 0.0F); this.head_mouth_top = new AdvancedModelBox(this, 0, 66); this.head_mouth_top.setRotationPoint(0.0F, -6.0F, -10.0F); this.head_mouth_top.addBox(-12.0F, 0.0F, -32.0F, 24, 6, 32, 0.0F); this.head_mouth_top.scaleX = 1.01F; this.fin_left = new AdvancedModelBox(this, 164, 0); this.fin_left.setRotationPoint(7.0F, 5.0F, 11.0F); this.fin_left.addBox(0.0F, -2.0F, -6.0F, 28, 4, 12, 0.0F); this.setRotateAngle(fin_left, 0.0F, -0.5918411493512771F, 0.6829473363053812F); this.fin_dorsal = new AdvancedModelBox(this, 0, 0); this.fin_dorsal.setRotationPoint(0.0F, -6.0F, 36.0F); this.fin_dorsal.addBox(-2.0F, -8.0F, -4.0F, 4, 8, 8, 0.0F); this.setRotateAngle(fin_dorsal, -0.5462880558742251F, 0.0F, 0.0F); this.tail_2.addChild(this.tail_3); this.head_mouth_top.addChild(this.head_mouth_top_1); this.main_body.addChild(this.main_head); this.main_body.addChild(this.tail_1); this.tail_3.addChild(this.tail_right); this.main_head.addChild(this.head_jaw_1); this.main_body.addChild(this.fin_right); this.head_jaw_1.addChild(this.head_jaw_2); this.tail_1.addChild(this.tail_2); this.tail_3.addChild(this.tail_left); this.main_head.addChild(this.head_mouth_top); this.main_body.addChild(this.fin_left); this.tail_1.addChild(this.fin_dorsal); bodyParts = new AdvancedModelBox[]{main_head, main_body, tail_1, tail_2, tail_3}; updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(main_body); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of(main_body, main_head, fin_left, tail_1, fin_right, head_mouth_top, head_jaw_1, head_mouth_top_1, head_jaw_2, fin_dorsal, tail_2, tail_3, tail_left, tail_right ); } public void setupAnim(EntityBaleenWhale whale, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); float globalSpeed = 0.6f; float globalDegree = 1f; // Model Parameters float fin_scale = whale.hasLongFins() ? 1.7F : 1; fin_left.scaleX = fin_scale; fin_right.scaleX = fin_scale; // Breathing Animation this.main_body.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.08F) + 0.01F, (float) (1F + Math.sin(ageInTicks / 16) * 0.08F), 1.0F); //this.main_head.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.08F), (float) (1F + Math.sin(ageInTicks / 16) * 0.08F), 1.0F); this.tail_1.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.04F), (float) (1F + Math.sin(ageInTicks / 16) * 0.04F), 1.0F); this.main_body.rotateAngleX = headPitch * ((float)Math.PI / 180F); this.main_body.rotateAngleY = netHeadYaw * ((float)Math.PI / 180F); //if (whale_shark.getDeltaMovement().horizontalDistanceSqr() > 1.0E-7D) { // this.main_body.rotateAngleX += -0.05F - 0.05F * Mth.cos(ageInTicks * 0.3F); // this.tail_1.rotateAngleX = -0.1F * Mth.cos(ageInTicks * 0.3F); // this.tail_2.rotateAngleX = -0.2F * Mth.cos(ageInTicks * 0.3F); //} // Pitch/Yaw handler if (whale.isInWater()) { this.setRotateAngle(main_body, Mth.clamp(whale.getXRot(), -20, 20) * ((float) Math.PI / 180F), 0, 0); } // Movement Animation float partialTicks = ageInTicks - whale.tickCount; float renderYaw = (float)whale.getMovementOffsets(0, partialTicks)[0]; if (!whale.isFeeding()) chainWave(bodyParts, globalSpeed * 0.3F, globalDegree * 0.6F, -5, limbSwing, limbSwingAmount); flap(fin_right, globalSpeed * 0.3F, globalDegree * 0.6F, true, 0, 0, limbSwing, limbSwingAmount); flap(fin_left, globalSpeed * 0.3F, globalDegree * 0.6F, false, 0, 0, limbSwing, limbSwingAmount); this.tail_1.rotateAngleY += smartClamp((float)whale.getMovementOffsets(15, partialTicks)[0] - renderYaw, -40, 40) * ((float) Math.PI / 180F); this.tail_2.rotateAngleY += smartClamp((float)whale.getMovementOffsets(17, partialTicks)[0] - renderYaw, -40, 40) * ((float) Math.PI / 180F); //this.main_body.rotateAngleZ += smartClamp((float)whale_shark.getMovementOffsets(7, partialTicks)[0] - renderYaw, -20, 20) * ((float) Math.PI / 180F); // Sitting Animation //if (whale.gulpProgress != 0) { //this.progressPosition(body_5, snake.sitProgress, -4.0F, 23.0F, -3.0F, 20); this.progressRotation(head_jaw_1, whale.gulpProgress, (float) Math.toRadians(57.39F), 0, 0, 50); this.progressPosition(head_jaw_2, whale.gulpProgress, 0, 6, 0, 50); this.head_jaw_1.scaleY = 1 + (float) (0.3 * whale.gulpProgress / 50F); this.head_jaw_2.scaleZ = 1 + (float) (0.3 * whale.gulpProgress / 50F); this.main_body.scaleX = 1 + (float) 0.1 * whale.gulpProgress / 50F; this.main_body.scaleY = 1 + (float) 0.1 * whale.gulpProgress / 50F; //} } // This wrapper handles cases where the returned MovementOffset is a large negative angle, which throws off the clamp function public float smartClamp(float angle, int min, int max) { float val = Math.abs(angle); if (val > 180) { angle = 360 - val; } return Mth.clamp(angle, min, max); } }
9,556
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelBoar.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelBoar.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityBoar; public class ModelBoar extends AdvancedEntityModel<EntityBoar> { public AdvancedModelBox main_body; public AdvancedModelBox head_main; public AdvancedModelBox leg_left_1; public AdvancedModelBox arm_left_1; public AdvancedModelBox shape14; public AdvancedModelBox shape15; public AdvancedModelBox arm_right_1; public AdvancedModelBox leg_right_1; public AdvancedModelBox head_snout; public AdvancedModelBox ear_left; public AdvancedModelBox head_mouth; public AdvancedModelBox ear_right; public AdvancedModelBox tusk_left; public AdvancedModelBox tusk_left_1; public AdvancedModelBox leg_left_2; public AdvancedModelBox arm_left_2; public AdvancedModelBox arm_right_2; public AdvancedModelBox leg_right_2; public AdvancedModelBox eye_left; public AdvancedModelBox eye_right; private final ModelAnimator animator; public ModelBoar() { this.texWidth = 64; this.texHeight = 64; this.shape14 = new AdvancedModelBox(this, 6, 0); this.shape14.setRotationPoint(0.0F, -5.0F, 6.0F); this.shape14.addBox(-1.5F, 0.0F, 0.0F, 3, 7, 0, 0.0F); this.setRotateAngle(shape14, 0.18203784098300857F, 0.0F, 0.0F); this.leg_right_1 = new AdvancedModelBox(this, 0, 36); this.leg_right_1.mirror = true; this.leg_right_1.setRotationPoint(-2.5F, -1.7F, 3.6F); this.leg_right_1.addBox(-2.0F, -1.0F, -2.0F, 4, 6, 5, 0.0F); this.setRotateAngle(leg_right_1, -0.136659280431156F, 0.0F, 0.13962634015954636F); this.head_main = new AdvancedModelBox(this, 0, 22); this.head_main.setRotationPoint(0.0F, -0.8F, -8.0F); this.head_main.addBox(-2.5F, -4.5F, -4.0F, 5, 7, 6, 0.0F); this.setRotateAngle(head_main, 0.31869712141416456F, 0.0F, 0.0F); this.tusk_left_1 = new AdvancedModelBox(this, 16, 24); this.tusk_left_1.setRotationPoint(-1.4F, 0.4F, -1.0F); this.tusk_left_1.addBox(0.0F, -2.0F, -1.0F, 0, 2, 1, 0.0F); this.setRotateAngle(tusk_left_1, 0.0F, 0.006773207605036283F, -0.36425021489121656F); this.tusk_left = new AdvancedModelBox(this, 16, 24); this.tusk_left.setRotationPoint(1.4F, 0.4F, -1.0F); this.tusk_left.addBox(0.0F, -2.0F, -1.0F, 0, 2, 1, 0.0F); this.setRotateAngle(tusk_left, 0.0F, 0.0F, 0.36425021489121656F); this.arm_right_2 = new AdvancedModelBox(this, 56, 10); this.arm_right_2.mirror = true; this.arm_right_2.setRotationPoint(0.0F, 4.5F, 0.01F); this.arm_right_2.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(arm_right_2, 0.0F, 0.0F, -0.136659280431156F); this.shape15 = new AdvancedModelBox(this, 34, 13); this.shape15.setRotationPoint(0.0F, -4.5F, -4.0F); this.shape15.addBox(-1.0F, -2.0F, -5.0F, 2, 2, 10, 0.0F); this.setRotateAngle(shape15, -0.045553093477052F, 0.0F, 0.0F); this.leg_right_2 = new AdvancedModelBox(this, 0, 47); this.leg_right_2.mirror = true; this.leg_right_2.setRotationPoint(0.4F, 3.7F, 2.0F); this.leg_right_2.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(leg_right_2, 0.18203784098300857F, 0.0F, -0.13962634015954636F); this.head_snout = new AdvancedModelBox(this, 22, 22); this.head_snout.setRotationPoint(0.0F, -0.8F, -3.0F); this.head_snout.addBox(-1.5F, -1.5F, -4.0F, 3, 3, 5, 0.0F); this.setRotateAngle(head_snout, 0.4553564018453205F, 0.0F, 0.0F); this.arm_right_1 = new AdvancedModelBox(this, 48, 0); this.arm_right_1.mirror = true; this.arm_right_1.setRotationPoint(-2.3F, -1.85F, -4.8F); this.arm_right_1.addBox(-1.5F, 0.0F, -2.0F, 3, 6, 4, 0.0F); this.setRotateAngle(arm_right_1, 0.045553093477052F, 0.0F, 0.136659280431156F); this.ear_right = new AdvancedModelBox(this, 16, 22); this.ear_right.mirror = true; this.ear_right.setRotationPoint(-1.1F, -3.4F, -0.3F); this.ear_right.addBox(-3.0F, -1.0F, 0.0F, 3, 2, 1, 0.0F); this.setRotateAngle(ear_right, -0.22759093446006054F, 0.091106186954104F, 1.0016444577195458F); this.head_mouth = new AdvancedModelBox(this, 18, 30); this.head_mouth.setRotationPoint(0.0F, 1.2F, -3.5F); this.head_mouth.addBox(-1.5F, 0.0F, -2.5F, 3, 1, 5, 0.0F); this.setRotateAngle(head_mouth, 0.091106186954104F, 0.0F, 0.0F); this.main_body = new AdvancedModelBox(this, 0, 0); this.main_body.setRotationPoint(0.0F, 15.6F, 0.0F); this.main_body.addBox(-3.5F, -5.0F, -8.0F, 7, 8, 14, 0.0F); this.setRotateAngle(main_body, -0.045553093477052F, 0.0F, 0.0F); this.leg_left_2 = new AdvancedModelBox(this, 0, 47); this.leg_left_2.setRotationPoint(-0.4F, 3.7F, 2.0F); this.leg_left_2.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(leg_left_2, 0.18203784098300857F, 0.0F, 0.13962634015954636F); this.arm_left_1 = new AdvancedModelBox(this, 48, 0); this.arm_left_1.setRotationPoint(2.3F, -1.85F, -4.8F); this.arm_left_1.addBox(-1.5F, 0.0F, -2.0F, 3, 6, 4, 0.0F); this.setRotateAngle(arm_left_1, 0.045553093477052F, 0.0F, -0.136659280431156F); this.leg_left_1 = new AdvancedModelBox(this, 0, 36); this.leg_left_1.setRotationPoint(2.5F, -1.7F, 3.6F); this.leg_left_1.addBox(-2.0F, -1.0F, -2.0F, 4, 6, 5, 0.0F); this.setRotateAngle(leg_left_1, -0.136659280431156F, 0.0F, -0.13962634015954636F); this.ear_left = new AdvancedModelBox(this, 16, 22); this.ear_left.setRotationPoint(1.1F, -3.4F, -0.3F); this.ear_left.addBox(0.0F, -1.0F, 0.0F, 3, 2, 1, 0.0F); this.setRotateAngle(ear_left, -0.22759093446006054F, -0.091106186954104F, -1.0016444577195458F); this.arm_left_2 = new AdvancedModelBox(this, 56, 10); this.arm_left_2.setRotationPoint(0.0F, 4.5F, 0.01F); this.arm_left_2.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(arm_left_2, 0.0F, 0.0F, 0.136659280431156F); this.eye_right = new AdvancedModelBox(this, 0, 20); this.eye_right.mirror = true; this.eye_right.setRotationPoint(-2.51F, -2.0F, -2.0F); this.eye_right.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.eye_left = new AdvancedModelBox(this, 0, 20); this.eye_left.setRotationPoint(2.51F, -2.0F, -2.0F); this.eye_left.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.head_main.addChild(this.eye_left); this.head_main.addChild(this.eye_right); this.main_body.addChild(this.shape14); this.main_body.addChild(this.leg_right_1); this.main_body.addChild(this.head_main); this.head_mouth.addChild(this.tusk_left_1); this.head_mouth.addChild(this.tusk_left); this.arm_right_1.addChild(this.arm_right_2); this.main_body.addChild(this.shape15); this.leg_right_1.addChild(this.leg_right_2); this.head_main.addChild(this.head_snout); this.main_body.addChild(this.arm_right_1); this.head_main.addChild(this.ear_right); this.head_main.addChild(this.head_mouth); this.leg_left_1.addChild(this.leg_left_2); this.main_body.addChild(this.arm_left_1); this.main_body.addChild(this.leg_left_1); this.head_main.addChild(this.ear_left); this.arm_left_1.addChild(this.arm_left_2); animator = ModelAnimator.create(); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.main_body); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( main_body, head_main, leg_left_1, arm_left_1, shape14, shape15, arm_right_1, leg_right_1, head_snout, ear_left, head_mouth, ear_right, tusk_left, tusk_left_1, leg_left_2, arm_left_2, arm_right_2, leg_right_2, eye_left, eye_right ); } void animate(IAnimatedEntity entityIn) { animator.update(entityIn); animator.setAnimation(EntityBoar.TALK); animator.startKeyframe(10); this.rotate(animator, head_mouth, 26.09F, 0, 0); this.rotate(animator, head_main, -26.09F, 0, 0); animator.endKeyframe(); animator.resetKeyframe(10); animator.setAnimation(EntityBoar.ATTACK); animator.startKeyframe(6); this.rotate(animator, head_main, 31.31F, 0, 26.08F); animator.endKeyframe(); animator.startKeyframe(4); this.rotate(animator, head_main, -26.08F, 0, -46.96F); animator.endKeyframe(); animator.resetKeyframe(4); animator.setAnimation(EntityBoar.WORK_DIG); animator.startKeyframe(6); this.rotate(animator, main_body, 13.04F, 0, 0); animator.move(head_main, 0, 2F, 1.9F); this.rotate(animator, head_main, 44.35F, 10.43F, 0); this.rotate(animator, arm_left_1, 15.65F, 0, -7.83F); this.rotate(animator, arm_left_2, -54.78F, 0, 7.83F); this.rotate(animator, arm_right_1, 15.65F, 0, 7.83F); this.rotate(animator, arm_right_2, -54.78F, 0, -7.83F); this.rotate(animator, leg_left_1, -23.48F, 0, -8); animator.move(leg_left_1, 0, 1F, 0); this.rotate(animator, leg_right_1, -23.48F, 0, 8); animator.move(leg_right_1, 0, 1F, 0); animator.endKeyframe(); for (int i = 0; i < 4; i++) { float head_angle = i % 2 == 0 ? -10.43F : 10.43F; animator.startKeyframe(8); this.rotate(animator, main_body, 13.04F, 0, 0); animator.move(head_main, 0, 2F, 1.9F); this.rotate(animator, head_main, 44.35F, head_angle, 0); this.rotate(animator, arm_left_1, 15.65F, 0, -7.83F); this.rotate(animator, arm_left_2, -54.78F, 0, 7.83F); this.rotate(animator, arm_right_1, 15.65F, 0, 7.83F); this.rotate(animator, arm_right_2, -54.78F, 0, -7.83F); this.rotate(animator, leg_left_1, -23.48F, 0, -8); animator.move(leg_left_1, 0, 1F, 0); this.rotate(animator, leg_right_1, -23.48F, 0, 8); animator.move(leg_right_1, 0, 1F, 0); animator.endKeyframe(); } animator.resetKeyframe(10); } public void setupAnim(EntityBoar boar, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); animate(boar); float globalSpeed = 1f; float globalDegree = 1f; limbSwingAmount = Math.min(limbSwingAmount, 0.4F); if (boar.isNoAi()) { limbSwing = ageInTicks; limbSwingAmount = 0.4F; } // Breathing Animation this.main_body.setScale((float) (1.0F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1.0F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); bob(main_body, 0.4F * globalSpeed, 0.1F, false, ageInTicks / 20, 2); bob(arm_right_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(arm_left_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_right_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_left_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); walk(head_main, 0.4f * globalSpeed, 0.03f, false, 2.4F, 0.08F, ageInTicks / 20, 2); if (boar.tickCount % 30 > 22) this.head_snout.setScale((float) (1.0F + Math.sin(ageInTicks / 6) * 0.1F + Math.sin(ageInTicks / 2) * 0.1F), (float) (1.0F + Math.sin(ageInTicks / 8) * 0.06F), 1.0F); if (boar.tickCount % 100 > 88) { swing(ear_left, 1.5f * globalSpeed, 0.6f * globalDegree, true, 0F, 0f, ageInTicks / 2.2F, limbSwingAmount); swing(ear_right, 1.5f * globalSpeed, 0.6f * globalDegree, true, 0.2F, 0f, ageInTicks / 2.2F, limbSwingAmount); } // Blinking Animation if (!boar.shouldRenderEyes()) { this.eye_right.setRotationPoint(-0.51F, -1.0F, -2.0F); this.eye_left.setRotationPoint(0.51F, -1.0F, -2.0F); } // Head Tracking Animation if (!boar.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 2, head_main); } // Pitch/Yaw handler if (boar.isInWater() && !boar.isOnGround()) { float pitch = Mth.clamp(boar.getXRot(), -20F, 20.0F) - 10; this.setRotateAngle(main_body, (float) (pitch * Math.PI / 180F), 0, 0); } // Movement Animation if (boar.canMove()) { if (boar.getCurrentSpeed() > 0.1f || boar.isAngry()) { // Running animation bob(main_body, 0.5F * globalSpeed, 0.8F, true, limbSwing, limbSwingAmount); walk(main_body, 0.5f * globalSpeed, 0.5f * globalDegree, true, 0.5F, 0f, limbSwing, limbSwingAmount); walk(head_main, 0.5f * globalSpeed, -0.5f * globalDegree, true, 0.5F, 0f, limbSwing, limbSwingAmount); flap(head_main, 0.25f * globalSpeed, -0.3f * globalDegree, true, 0.5F, 0f, limbSwing, limbSwingAmount); bob(head_main, 0.5F * globalSpeed, 0.8F, true, limbSwing, limbSwingAmount); bob(arm_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right_1, 0.5f * globalSpeed, 1.4f * globalDegree, true, 0F, 0.4f, limbSwing, limbSwingAmount); walk(arm_right_2, 0.5f * globalSpeed, 0.8f * globalDegree, true, 0.2F, 0.6f, limbSwing, limbSwingAmount); bob(arm_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left_1, 0.5f * globalSpeed, 1.4f * globalDegree, true, 0.6F, 0.4f, limbSwing, limbSwingAmount); walk(arm_left_2, 0.5f * globalSpeed, 0.8f * globalDegree, true, 0.8F, 0.6f, limbSwing, limbSwingAmount); bob(leg_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_1, 0.5f * globalSpeed, 1f * globalDegree, true, 1.4F, -0.4f, limbSwing, limbSwingAmount); walk(leg_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 1.6F, -0.6f, limbSwing, limbSwingAmount); bob(leg_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_1, 0.5f * globalSpeed, 1f * globalDegree, true, 2F, -0.4F, limbSwing, limbSwingAmount); walk(leg_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 2.2F, -0.6f, limbSwing, limbSwingAmount); flap(shape14, 0.5F * globalSpeed, 1.4F * globalDegree, false, 0, 0.2F, limbSwing, limbSwingAmount); walk(shape14, 0.5F * globalSpeed, 1.8F * globalDegree, false, 1.0F, 1.8F, limbSwing, limbSwingAmount); } else { // Walking Animation bob(main_body, 0.5F * globalSpeed, 0.8F, true, limbSwing, limbSwingAmount); bob(arm_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right_1, 0.5f * globalSpeed, globalDegree, true, 0F, 0f, limbSwing, limbSwingAmount); walk(arm_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 0.2F, 0.2f, limbSwing, limbSwingAmount); bob(arm_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left_1, 0.5f * globalSpeed, globalDegree, true, 2.4F, 0f, limbSwing, limbSwingAmount); walk(arm_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 2.6F, 0.2f, limbSwing, limbSwingAmount); bob(leg_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_1, 0.5f * globalSpeed, globalDegree, true, 1F, 0f, limbSwing, limbSwingAmount); walk(leg_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 1.2F, 0.2f, limbSwing, limbSwingAmount); bob(leg_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_1, 0.5f * globalSpeed, globalDegree, true, 3.4F, 0f, limbSwing, limbSwingAmount); walk(leg_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 3.6F, 0.2f, limbSwing, limbSwingAmount); flap(shape14, 0.5F * globalSpeed, 1.4F * globalDegree, false, 0, 0.2F, limbSwing, limbSwingAmount); swing(shape14, 0.5F * globalSpeed, 0.8F * globalDegree, false, 1.0F, 0.2F, limbSwing, limbSwingAmount); } } // Sitting Animation if (boar.sitProgress > 0) { this.progressPosition(main_body, boar.sitProgress, 0.0F, 21.60F, 0.0F, 40); this.progressRotation(main_body, boar.sitProgress, (float) Math.toRadians(-2.61F), (float) Math.toRadians(5.22F), 0, 40); this.progressRotation(head_main, boar.sitProgress, 0, (float) Math.toRadians(-23.48F), 0, 40); this.progressRotation(arm_right_1, boar.sitProgress, (float) Math.toRadians(-20.87F), 0, (float) Math.toRadians(7.83F), 40); this.progressRotation(arm_right_2, boar.sitProgress, (float) Math.toRadians(-65.22F), 0, (float) Math.toRadians(-7.83F), 40); this.progressRotation(arm_left_1, boar.sitProgress, (float) Math.toRadians(-26.09F), (float) Math.toRadians(20.87F), (float) Math.toRadians(-7.83F), 40); this.progressRotation(arm_left_2, boar.sitProgress, (float) Math.toRadians(-57.39F), 0, (float) Math.toRadians(7.83F), 40); this.progressRotation(leg_left_2, boar.sitProgress, (float) Math.toRadians(-83.48F), (float) Math.toRadians(-20.87F), (float) Math.toRadians(8.00F), 40); this.progressRotation(leg_right_2, boar.sitProgress, (float) Math.toRadians(-83.48F), (float) Math.toRadians(20.87F), (float) Math.toRadians(-8.00F), 40); } // Sleeping Animation if (boar.sleepProgress > 0) { this.progressPosition(main_body, boar.sleepProgress, 0.0F, 21F, 0.0F, 40); this.progressRotation(main_body, boar.sleepProgress, (float) Math.toRadians(20.87F), 0.0F, (float) Math.toRadians(-91.30), 40); this.progressRotation(head_main, boar.sleepProgress, (float) Math.toRadians(26.09), (float) Math.toRadians(15.65), 0, 40); this.progressRotation(arm_left_1, boar.sleepProgress, (float) Math.toRadians(5.22), 0, (float) Math.toRadians(23.48), 40); this.progressRotation(leg_left_1, boar.sleepProgress, (float) Math.toRadians(10.43), 0, (float) Math.toRadians(36.52), 40); } } }
19,305
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelBoarPiglet.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelBoarPiglet.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityBoar; public class ModelBoarPiglet extends AdvancedEntityModel<EntityBoar> { public AdvancedModelBox main_body; public AdvancedModelBox leg_right; public AdvancedModelBox leg_left; public AdvancedModelBox head_main; public AdvancedModelBox arm_right; public AdvancedModelBox arm_left; public AdvancedModelBox shape14; public AdvancedModelBox head_snout; public AdvancedModelBox ear_left; public AdvancedModelBox ear_right; public AdvancedModelBox eye_left; public AdvancedModelBox eye_right; public ModelBoarPiglet() { this.texWidth = 64; this.texHeight = 64; this.arm_left = new AdvancedModelBox(this, 42, 40); this.arm_left.setRotationPoint(1.3F, 0.2F, -2.99F); this.arm_left.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(arm_left, 0.045553093477052F, 0.0F, 0.0F); this.shape14 = new AdvancedModelBox(this, 42, 59); this.shape14.setRotationPoint(0.0F, -2.5F, 4.0F); this.shape14.addBox(-1.5F, 0.0F, 0.0F, 3, 3, 0, 0.0F); this.setRotateAngle(shape14, 0.18203784098300857F, 0.0F, 0.0F); this.main_body = new AdvancedModelBox(this, 24, 40); this.main_body.setRotationPoint(0.0F, 18.0F, 0.0F); this.main_body.addBox(-2.0F, -2.5F, -4.0F, 4, 5, 8, 0.0F); this.setRotateAngle(main_body, -0.045553093477052F, 0.0F, 0.0F); this.ear_right = new AdvancedModelBox(this, 24, 43); this.ear_right.mirror = true; this.ear_right.setRotationPoint(-1.1F, -1.2F, -1.5F); this.ear_right.addBox(-3.0F, -1.0F, 0.0F, 3, 2, 1, 0.0F); this.setRotateAngle(ear_right, 0.27314402793711257F, 0.7740535232594852F, 0.5462880558742251F); this.eye_right = new AdvancedModelBox(this, 0, 20); this.eye_right.setRotationPoint(-2.01F, -1.0F, -2.0F); this.eye_right.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.leg_right = new AdvancedModelBox(this, 42, 40); this.leg_right.mirror = true; this.leg_right.setRotationPoint(-1.3F, -0.3F, 3.0F); this.leg_right.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(leg_right, 0.045553093477052F, 0.0F, 0.0F); this.eye_left = new AdvancedModelBox(this, 0, 20); this.eye_left.setRotationPoint(2.01F, -1.0F, -2.0F); this.eye_left.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.ear_left = new AdvancedModelBox(this, 24, 43); this.ear_left.setRotationPoint(1.1F, -1.2F, -1.5F); this.ear_left.addBox(0.0F, -1.0F, 0.0F, 3, 2, 1, 0.0F); this.setRotateAngle(ear_left, 0.27314402793711257F, -0.7740535232594852F, -0.5462880558742251F); this.leg_left = new AdvancedModelBox(this, 42, 40); this.leg_left.setRotationPoint(1.3F, -0.3F, 3.0F); this.leg_left.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(leg_left, 0.045553093477052F, 0.0F, 0.0F); this.head_main = new AdvancedModelBox(this, 24, 53); this.head_main.setRotationPoint(0.0F, -0.8F, -3.0F); this.head_main.addBox(-2.0F, -2.5F, -4.0F, 4, 4, 4, 0.0F); this.setRotateAngle(head_main, 0.31869712141416456F, 0.0F, 0.0F); this.arm_right = new AdvancedModelBox(this, 42, 40); this.arm_right.mirror = true; this.arm_right.setRotationPoint(-1.3F, 0.0F, -2.99F); this.arm_right.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(arm_right, 0.045553093477052F, 0.0F, 0.0F); this.head_snout = new AdvancedModelBox(this, 40, 53); this.head_snout.setRotationPoint(0.0F, -0.5F, -2.7F); this.head_snout.addBox(-1.5F, -1.0F, -3.0F, 3, 3, 3, 0.0F); this.setRotateAngle(head_snout, 0.18203784098300857F, 0.0F, 0.0F); this.main_body.addChild(this.arm_left); this.main_body.addChild(this.shape14); this.head_main.addChild(this.ear_right); this.head_main.addChild(this.eye_right); this.main_body.addChild(this.leg_right); this.head_main.addChild(this.eye_left); this.head_main.addChild(this.ear_left); this.main_body.addChild(this.leg_left); this.main_body.addChild(this.head_main); this.main_body.addChild(this.arm_right); this.head_main.addChild(this.head_snout); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.main_body); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( main_body, leg_right, leg_left, head_main, arm_right, arm_left, shape14, head_snout, ear_left, ear_right, eye_left, eye_right ); } public void setupAnim(EntityBoar bear, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); // Breathing Animation this.main_body.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); bob(main_body, 0.4F * 1.5f, 0.03F, false, ageInTicks / 20, 2); bob(arm_right, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(arm_left, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(leg_right, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(leg_left, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); // Blinking Animation if (!bear.shouldRenderEyes()) { this.eye_right.setRotationPoint(-0.49F, 0, -2F); this.eye_left.setRotationPoint(0.49F, 0, -2F); } // Head Tracking Animation this.faceTarget(netHeadYaw, headPitch, 1, head_main); // Movement Animation if (bear.canMove()) { this.arm_right.rotateAngleX = Mth.cos(limbSwing * 0.5F) * 1.4F * limbSwingAmount; this.arm_left.rotateAngleX = Mth.cos(limbSwing * 0.5F + (float)Math.PI) * 1.4F * limbSwingAmount; this.leg_right.rotateAngleX = Mth.cos(limbSwing * 0.5F + (float)Math.PI) * 1.4F * limbSwingAmount; this.leg_left.rotateAngleX = Mth.cos(limbSwing * 0.5F) * 1.4F * limbSwingAmount; } // Sleeping Animation else if (bear.sitProgress > 0) { this.progressRotation(leg_right, bear.sitProgress, 1.5025539530419183F, -0.40980330836826856F, 0.0F, 40); this.progressRotation(leg_left, bear.sitProgress, 1.5025539530419183F, 0.40980330836826856F, 0.0F, 40); this.progressRotation(arm_left, bear.sitProgress, -1.3658946726107624F, -0.36425021489121656F, 0.0F, 40); this.progressRotation(arm_right, bear.sitProgress, -1.3658946726107624F, 0.36425021489121656F, 0.0F, 40); this.progressPosition(main_body, bear.sitProgress, 0.0F, 22.0F, -2.0F, 40); this.progressPosition(head_main, bear.sitProgress, 0.0F, -0.5F, -2.5F, 40); this.progressPosition(arm_right, bear.sitProgress, -1F, 1.0F, -1.0F, 40); this.progressPosition(arm_left, bear.sitProgress, 1F, 1.0F, -1.0F, 40); this.progressPosition(leg_right, bear.sitProgress, -1.3F, 1.0F, 1.0F, 40); this.progressPosition(leg_left, bear.sitProgress, 1.3F, 1.0F, 1.0F, 40); } // Sleeping Animation else if (bear.sleepProgress > 0) { this.progressRotation(leg_right, bear.sleepProgress, 1.5025539530419183F, -0.40980330836826856F, 0.0F, 40); this.progressRotation(leg_left, bear.sleepProgress, 1.5025539530419183F, 0.40980330836826856F, 0.0F, 40); this.progressRotation(arm_left, bear.sleepProgress, -1.3658946726107624F, -0.36425021489121656F, 0.0F, 40); this.progressRotation(arm_right, bear.sleepProgress, -1.3658946726107624F, 0.36425021489121656F, 0.0F, 40); this.progressPosition(main_body, bear.sleepProgress, 0.0F, 22.0F, -2.0F, 40); this.progressPosition(head_main, bear.sleepProgress, 0.0F, -0.5F, -2.5F, 40); this.progressPosition(arm_right, bear.sleepProgress, -1F, 1.0F, -1.0F, 40); this.progressPosition(arm_left, bear.sleepProgress, 1F, 1.0F, -1.0F, 40); this.progressPosition(leg_right, bear.sleepProgress, -1.3F, 1.0F, 1.0F, 40); this.progressPosition(leg_left, bear.sleepProgress, 1.3F, 1.0F, 1.0F, 40); } } }
8,890
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelOpossum.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelOpossum.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import untamedwilds.entity.mammal.EntityOpossum; public class ModelOpossum extends AdvancedEntityModel<EntityOpossum> { public AdvancedModelBox body_main; public AdvancedModelBox arm_left_1; public AdvancedModelBox arm_right_1; public AdvancedModelBox head_head; public AdvancedModelBox leg_right_1; public AdvancedModelBox leg_left_1; public AdvancedModelBox joey_1; public AdvancedModelBox joey_2; public AdvancedModelBox joey_3; public AdvancedModelBox arm_left_2; public AdvancedModelBox arm_left_paw; public AdvancedModelBox arm_right_2; public AdvancedModelBox arm_right_paw; public AdvancedModelBox head_ear_left; public AdvancedModelBox head_ear_right; public AdvancedModelBox head_snout; public AdvancedModelBox eye_left; public AdvancedModelBox eye_right; public AdvancedModelBox head_jaw; public AdvancedModelBox whisker_right; public AdvancedModelBox whisker_left; public AdvancedModelBox leg_right_2; public AdvancedModelBox leg_right_paw; public AdvancedModelBox leg_left_2; public AdvancedModelBox leg_left_paw; public AdvancedModelBox tail_1; public AdvancedModelBox tail_2; private final ModelAnimator animator; public ModelOpossum() { this.texWidth = 64; this.texHeight = 32; this.joey_1 = new AdvancedModelBox(this, 40, 0); this.joey_1.setRotationPoint(0.0F, -5.0F, 0.0F); this.joey_1.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); this.setRotateAngle(joey_1, 0.0F, 0.0F, -0.5462880558742251F); this.head_jaw = new AdvancedModelBox(this, 6, 17); this.head_jaw.setRotationPoint(0.0F, 1.01F, -2.0F); this.head_jaw.addBox(-1.0F, 0.0F, -4.0F, 2, 1, 4, 0.0F); this.arm_left_2 = new AdvancedModelBox(this, 30, 23); this.arm_left_2.mirror = true; this.arm_left_2.setRotationPoint(0.0F, 3.5F, 0.01F); this.arm_left_2.addBox(-1.0F, 0.0F, -1.0F, 2, 3, 2, 0.0F); this.setRotateAngle(arm_left_2, 0.0F, 0.0F, 0.136659280431156F); this.body_main = new AdvancedModelBox(this, 0, 0); this.body_main.setRotationPoint(0.0F, 19.0F, -3.8F); this.body_main.addBox(-2.5F, -3.3F, -2.0F, 5, 5, 10, 0.0F); this.whisker_right = new AdvancedModelBox(this, 0, 0); this.whisker_right.setRotationPoint(-0.6F, 0.0F, -3.0F); this.whisker_right.addBox(-3.0F, -1.5F, 0.0F, 3, 3, 0, 0.0F); this.setRotateAngle(whisker_right, 0.0F, -0.22759093446006054F, -0.27314402793711257F); this.arm_left_paw = new AdvancedModelBox(this, 0, 4); this.arm_left_paw.mirror = true; this.arm_left_paw.setRotationPoint(0.5F, 3.02F, 1.0F); this.arm_left_paw.addBox(-1.5F, 0.0F, -3.0F, 3, 0, 4, 0.0F); this.leg_right_2 = new AdvancedModelBox(this, 46, 24); this.leg_right_2.setRotationPoint(0.0F, 3.1F, 1.2F); this.leg_right_2.addBox(-1.0F, 0.0F, -1.0F, 2, 3, 2, 0.0F); this.setRotateAngle(leg_right_2, 0.27314402793711257F, 0.0F, -0.13962634015954636F); this.eye_left = new AdvancedModelBox(this, 0, 17); this.eye_left.setRotationPoint(0.01F, 0.0F, -3.01F); this.eye_left.addBox(0.0F, -1.0F, -1.0F, 2, 1, 1, 0.0F); this.tail_2 = new AdvancedModelBox(this, 14, 17); this.tail_2.setRotationPoint(0.0F, 0.1F, 3.9F); this.tail_2.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 6, 0.0F); this.setRotateAngle(tail_2, 0.1366592804F, 0.0F, 0.0F); this.tail_2.scaleX = 0.75F; this.arm_right_2 = new AdvancedModelBox(this, 30, 23); this.arm_right_2.setRotationPoint(0.0F, 3.5F, 0.01F); this.arm_right_2.addBox(-1.0F, 0.0F, -1.0F, 2, 3, 2, 0.0F); this.setRotateAngle(arm_right_2, 0.0F, 0.0F, -0.136659280431156F); this.leg_left_1 = new AdvancedModelBox(this, 46, 15); this.leg_left_1.mirror = true; this.leg_left_1.setRotationPoint(1.5F, -1.3F, 6.8F); this.leg_left_1.addBox(-1.5F, -1.0F, -2.0F, 3, 5, 4, 0.0F); this.setRotateAngle(leg_left_1, -0.27314402793711257F, 0.0F, -0.13962634015954636F); this.head_ear_left = new AdvancedModelBox(this, 0, 21); this.head_ear_left.setRotationPoint(1.3F, -1.3F, -1.5F); this.head_ear_left.addBox(-1.0F, -2.0F, 0.0F, 2, 2, 1, 0.0F); this.setRotateAngle(head_ear_left, -0.091106186954104F, -0.091106186954104F, 0.8651597102135892F); this.whisker_left = new AdvancedModelBox(this, 0, 0); this.whisker_left.mirror = true; this.whisker_left.setRotationPoint(0.6F, 0.0F, -3.0F); this.whisker_left.addBox(0.0F, -1.5F, 0.0F, 3, 3, 0, 0.0F); this.setRotateAngle(whisker_left, 0.0F, 0.22759093446006054F, 0.27314402793711257F); this.head_head = new AdvancedModelBox(this, 2, 22); this.head_head.setRotationPoint(0.0F, -1.0F, -1.9F); this.head_head.addBox(-2.0F, -2.0F, -4.0F, 4, 4, 4, 0.0F); this.setRotateAngle(head_head, 0.091106186954104F, 0.0F, 0.0F); this.leg_left_paw = new AdvancedModelBox(this, 0, 4); this.leg_left_paw.mirror = true; this.leg_left_paw.setRotationPoint(0.5F, 3.01F, 1.0F); this.leg_left_paw.addBox(-1.5F, 0.0F, -3.0F, 3, 0, 4, 0.0F); this.setRotateAngle(leg_left_paw, 0.0036651914291880917F, 0.0F, 0.0F); this.head_snout = new AdvancedModelBox(this, 18, 26); this.head_snout.setRotationPoint(0.0F, 1.0F, -2.0F); this.head_snout.addBox(-1.0F, -1.0F, -4.0F, 2, 2, 2, 0.0F); this.arm_right_1 = new AdvancedModelBox(this, 28, 15); this.arm_right_1.setRotationPoint(-1.5F, -1.55F, 0.2F); this.arm_right_1.addBox(-1.5F, 0.0F, -1.5F, 3, 4, 3, 0.0F); this.setRotateAngle(arm_right_1, 0.0F, 0.0F, 0.136659280431156F); this.leg_right_1 = new AdvancedModelBox(this, 46, 15); this.leg_right_1.setRotationPoint(-1.5F, -1.3F, 6.8F); this.leg_right_1.addBox(-1.5F, -1.0F, -2.0F, 3, 5, 4, 0.0F); this.setRotateAngle(leg_right_1, -0.27314402793711257F, 0.0F, 0.13962634015954636F); this.leg_right_paw = new AdvancedModelBox(this, 0, 4); this.leg_right_paw.setRotationPoint(-0.5F, 3.01F, 1.0F); this.leg_right_paw.addBox(-1.5F, 0.0F, -3.0F, 3, 0, 4, 0.0F); this.setRotateAngle(leg_right_paw, 0.0036651914291880917F, 0.0F, 0.0F); this.joey_2 = new AdvancedModelBox(this, 40, 0); this.joey_2.mirror = true; this.joey_2.setRotationPoint(0.0F, -5.0F, 3.0F); this.joey_2.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); this.setRotateAngle(joey_2, 0.0F, 0.0F, 0.5462880558742251F); this.joey_3 = new AdvancedModelBox(this, 40, 0); this.joey_3.setRotationPoint(0.0F, -5.0F, 6.0F); this.joey_3.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); this.setRotateAngle(joey_3, 0.0F, 0.0F, -0.5462880558742251F); this.tail_1 = new AdvancedModelBox(this, 24, 2); this.tail_1.setRotationPoint(0.0F, -2.0F, 7.5F); this.tail_1.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 4, 0.0F); this.setRotateAngle(tail_1, -0.4098033084F, 0.0F, 0.0F); this.arm_right_paw = new AdvancedModelBox(this, 0, 4); this.arm_right_paw.setRotationPoint(-0.5F, 3.02F, 1.0F); this.arm_right_paw.addBox(-1.5F, 0.0F, -3.0F, 3, 0, 4, 0.0F); this.eye_right = new AdvancedModelBox(this, 0, 17); this.eye_right.mirror = true; this.eye_right.setRotationPoint(-0.01F, 0.0F, -3.01F); this.eye_right.addBox(-2.0F, -1.0F, -1.0F, 2, 1, 1, 0.0F); this.head_ear_right = new AdvancedModelBox(this, 0, 21); this.head_ear_right.mirror = true; this.head_ear_right.setRotationPoint(-1.3F, -1.2F, -1.5F); this.head_ear_right.addBox(-1.0F, -2.0F, 0.0F, 2, 2, 1, 0.0F); this.setRotateAngle(head_ear_right, -0.091106186954104F, 0.091106186954104F, -0.8651597102135892F); this.arm_left_1 = new AdvancedModelBox(this, 28, 15); this.arm_left_1.mirror = true; this.arm_left_1.setRotationPoint(1.5F, -1.55F, 0.2F); this.arm_left_1.addBox(-1.5F, 0.0F, -1.5F, 3, 4, 3, 0.0F); this.setRotateAngle(arm_left_1, 0.0F, 0.0F, -0.136659280431156F); this.leg_left_2 = new AdvancedModelBox(this, 46, 24); this.leg_left_2.mirror = true; this.leg_left_2.setRotationPoint(0.0F, 3.1F, 1.2F); this.leg_left_2.addBox(-1.0F, 0.0F, -1.0F, 2, 3, 2, 0.0F); this.setRotateAngle(leg_left_2, 0.27314402793711257F, 0.0F, 0.13962634015954636F); this.body_main.addChild(this.joey_1); this.head_head.addChild(this.head_jaw); this.arm_left_1.addChild(this.arm_left_2); this.head_snout.addChild(this.whisker_right); this.arm_left_2.addChild(this.arm_left_paw); this.leg_right_1.addChild(this.leg_right_2); this.head_head.addChild(this.eye_left); this.tail_1.addChild(this.tail_2); this.arm_right_1.addChild(this.arm_right_2); this.body_main.addChild(this.leg_left_1); this.head_head.addChild(this.head_ear_left); this.head_snout.addChild(this.whisker_left); this.body_main.addChild(this.head_head); this.leg_left_2.addChild(this.leg_left_paw); this.head_head.addChild(this.head_snout); this.body_main.addChild(this.arm_right_1); this.body_main.addChild(this.leg_right_1); this.leg_right_2.addChild(this.leg_right_paw); this.body_main.addChild(this.joey_2); this.body_main.addChild(this.joey_3); this.body_main.addChild(this.tail_1); this.arm_right_2.addChild(this.arm_right_paw); this.head_head.addChild(this.eye_right); this.head_head.addChild(this.head_ear_right); this.body_main.addChild(this.arm_left_1); this.leg_left_1.addChild(this.leg_left_2); animator = ModelAnimator.create(); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of(body_main, arm_left_1, arm_right_1, head_head, leg_right_1, leg_left_1, tail_1, joey_1, joey_2, joey_3, arm_left_2, arm_left_paw, arm_right_2, arm_right_paw, head_ear_left, head_ear_right, head_snout, eye_left, eye_right, head_jaw, whisker_right, whisker_left, leg_right_2, leg_right_paw, leg_left_2, leg_left_paw, tail_2); } private void animate(IAnimatedEntity entityIn) { EntityOpossum monitor = (EntityOpossum) entityIn; animator.update(monitor); animator.setAnimation(EntityOpossum.THREAT_BACK_OFF); int invert = 1; for (int i = 0; i < 4; i++) { animator.startKeyframe(6); animator.move(head_snout, 0, -1F, 0); this.rotate(animator, head_head, -15.65F, 2.61F * invert, 13.04F * invert); this.rotate(animator, head_jaw, 44.35F, 0, 0); invert = invert * -1; animator.endKeyframe(); } animator.resetKeyframe(6); animator.setAnimation(EntityOpossum.IDLE_SCRATCH); animator.startKeyframe(8); this.rotate(animator, body_main, 0, 7.83F, -7.83F); this.rotate(animator, head_head, -23.48F, 20.87F, -39.13F); this.rotate(animator, tail_1, -23.48F, -15.65F, 0); this.rotate(animator, head_ear_right, -28.70F, 5.22F, -49.57F); animator.move(arm_right_1, 0, -0.3F, 0); this.rotate(animator, arm_right_1, 0, 0, 13.04F); this.rotate(animator, leg_left_1, -15.65F, 0, 2.61F); animator.move(leg_right_1, 0, 0, -1); this.rotate(animator, leg_right_1, -60F, 18.26F, 8F); animator.move(leg_right_paw, 0, -1, -1); this.rotate(animator, leg_right_paw, 88.70F, 0, 0); int leg_offset = 1; for (int i = 0; i < 6; i++) { animator.startKeyframe(4); this.rotate(animator, body_main, 0, 7.83F, -7.83F); this.rotate(animator, head_head, -23.48F, 20.87F - 10 * leg_offset, -39.13F - 10 * leg_offset); this.rotate(animator, tail_1, -23.48F, -15.65F, 0); this.rotate(animator, head_ear_right, -28.70F, 5.22F, -49.57F); animator.move(arm_right_1, 0, -0.3F, 0); this.rotate(animator, arm_right_1, 0, 0, 13.04F); this.rotate(animator, leg_left_1, -15.65F, 0, 2.61F); animator.move(leg_right_1, 0, 0, -1); this.rotate(animator, leg_right_1, -80 - 20 * leg_offset, 18.26F, 8F); animator.move(leg_right_paw, 0, -1, -1); this.rotate(animator, leg_right_paw, 88.70F, 0, 0); leg_offset = leg_offset * -1; animator.endKeyframe(); } animator.resetKeyframe(8); } public void setupAnim(EntityOpossum opossum, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { resetToDefaultPose(); animate(opossum); float globalSpeed = 1.6f; float globalDegree = 1.4f; limbSwingAmount = Math.min(0.5F, limbSwingAmount); if (opossum.isNoAi()) { limbSwing = ageInTicks / 4; limbSwingAmount = 0.5F; } // Breathing Animation if (!opossum.isPlayingDead()) { this.body_main.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.head_head.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), 1.0F, 1.0F); swing(this.whisker_left, globalSpeed, 0.12F * globalDegree, false, 1F, 0, ageInTicks / 6, 2); swing(this.whisker_right, globalSpeed, 0.12F * globalDegree, true, 1F, 0, ageInTicks / 6, 2);//this.head_jaw.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); AdvancedModelBox[] bodyParts = new AdvancedModelBox[]{tail_1, tail_2}; chainSwing(bodyParts, 0.3F * globalSpeed, 0.125F * globalDegree, 1F, ageInTicks / 6, 1); } this.joey_1.showModel = opossum.getJoeys() >= 1; this.joey_2.showModel = opossum.getJoeys() >= 2; this.joey_3.showModel = opossum.getJoeys() >= 3; // Head Tracking Animation if (!opossum.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 2, head_head); } // Pitch/Yaw handler if (opossum.isInWater() && !opossum.isOnGround()) { this.setRotateAngle(body_main, opossum.getXRot() * ((float) Math.PI / 180F), 0, 0); } // Movement Animation if (opossum.isInWater()) { flap(arm_left_1, globalSpeed, globalDegree, false, 0.8F, 1f, limbSwing, limbSwingAmount); flap(leg_left_1, globalSpeed, globalDegree * 0.8f, false, 1.6F, 1f, limbSwing, limbSwingAmount); flap(arm_right_1, globalSpeed, globalDegree, false, 2.4F, 1f, limbSwing, limbSwingAmount); flap(leg_right_1, globalSpeed, globalDegree * 0.8f, false, 3.2F, 1f, limbSwing, limbSwingAmount); flap(body_main, globalSpeed / 2, globalDegree * 1.2f, false, 0, 0.1f, limbSwing / 2, limbSwingAmount); swing(body_main, globalSpeed / 2, globalDegree * 1.2f, false, 0.8F, 0.1f, limbSwing / 3, limbSwingAmount); chainWave(new AdvancedModelBox[]{head_head, body_main}, globalSpeed * 0.8F, globalDegree, -4, limbSwing, limbSwingAmount * 0.2F); } else { bob(body_main, 0.5F * globalSpeed, 0.8F, true, limbSwing, limbSwingAmount); bob(arm_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right_1, 0.5f * globalSpeed, globalDegree, true, 0F, 0f, limbSwing, limbSwingAmount); walk(arm_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 0.2F, 0.2f, limbSwing, limbSwingAmount); bob(arm_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left_1, 0.5f * globalSpeed, globalDegree, true, 2.4F, 0f, limbSwing, limbSwingAmount); walk(arm_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 2.6F, 0.2f, limbSwing, limbSwingAmount); bob(leg_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_1, 0.5f * globalSpeed, globalDegree, true, 1F, 0f, limbSwing, limbSwingAmount); walk(leg_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 1.2F, 0.2f, limbSwing, limbSwingAmount); bob(leg_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_1, 0.5f * globalSpeed, globalDegree, true, 3.4F, 0f, limbSwing, limbSwingAmount); walk(leg_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 3.6F, 0.2f, limbSwing, limbSwingAmount); } // Sitting Animation if (opossum.sitProgress != 0) { body_main.setScaleY(1 + 0.4F * (float) opossum.sitProgress / 20); this.progressPosition(body_main, opossum.sitProgress, 0, 22F, -3.8F, 20); this.progressPosition(arm_left_1, opossum.sitProgress, 1.5F, -2.55F, 0.2F, 20); this.progressPosition(arm_left_2, opossum.sitProgress, 0, 1.5F, 0.01F, 20); this.progressPosition(arm_right_1, opossum.sitProgress, -1.5F, -2.55F, 0.2F, 20); this.progressPosition(arm_right_2, opossum.sitProgress, 0, 1.5F, 0.01F, 20); this.progressPosition(leg_left_1, opossum.sitProgress, 1.5F, -2.3F, 6.8F, 20); this.progressPosition(leg_left_2, opossum.sitProgress, 0, 1, 1.2F, 20); this.progressPosition(leg_right_1, opossum.sitProgress, -1.5F, -2.3F, 6.8F, 20); this.progressPosition(leg_right_2, opossum.sitProgress, 0, 1, 1.2F, 20); } // Sleeping Animation if (opossum.sleepProgress != 0) { this.progressRotation(body_main, opossum.sleepProgress, 0, 0, (float) Math.toRadians(-80.65F), 40); this.progressPosition(body_main, opossum.sleepProgress, -1, 22F, -1.8F, 40); this.progressRotation(head_head, opossum.sleepProgress, (float) Math.toRadians(20.87F), 0, (float) Math.toRadians(-18.26F), 40); if (opossum.isPlayingDead()) this.progressRotation(head_jaw, opossum.sleepProgress, (float) Math.toRadians(46.96F), 0, (float) Math.toRadians(23.48F), 40); this.progressRotation(arm_left_1, opossum.sleepProgress, 0, (float) Math.toRadians(7.83F), (float) Math.toRadians(10.43F), 40); this.progressRotation(leg_left_1, opossum.sleepProgress, (float) Math.toRadians(-36.52F), (float) Math.toRadians(2.61F), (float) Math.toRadians(5.22F), 40); this.progressRotation(tail_1, opossum.sleepProgress, (float) Math.toRadians(-65.22F), 0, 0, 40); this.progressRotation(tail_2, opossum.sleepProgress, (float) Math.toRadians(-44.35F), 0, 0, 40); } } }
19,415
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelWarthog.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelWarthog.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityBoar; public class ModelWarthog extends AdvancedEntityModel<EntityBoar> { public AdvancedModelBox main_body; public AdvancedModelBox head_main; public AdvancedModelBox leg_left_1; public AdvancedModelBox arm_left_1; public AdvancedModelBox shape14; public AdvancedModelBox shape15; public AdvancedModelBox arm_right_1; public AdvancedModelBox leg_right_1; public AdvancedModelBox head_snout; public AdvancedModelBox ear_left; public AdvancedModelBox head_mouth; public AdvancedModelBox ear_right; public AdvancedModelBox eye_left; public AdvancedModelBox cheek_right; public AdvancedModelBox cheek_left; public AdvancedModelBox eye_right; public AdvancedModelBox tusk_right; public AdvancedModelBox tusk_left; public AdvancedModelBox leg_left_2; public AdvancedModelBox arm_left_2; public AdvancedModelBox arm_right_2; public AdvancedModelBox leg_right_2; private final ModelAnimator animator; public ModelWarthog() { this.texWidth = 64; this.texHeight = 64; this.tusk_right = new AdvancedModelBox(this, 20, 38); this.tusk_right.setRotationPoint(-2.5F, 0.7F, -2.0F); this.tusk_right.addBox(0.0F, -2.0F, -1.0F, 1, 3, 2, 0.0F); this.setRotateAngle(tusk_right, 0.0F, -0.045553093477052F, -1.1838568316277536F); this.ear_right = new AdvancedModelBox(this, 16, 22); this.ear_right.mirror = true; this.ear_right.setRotationPoint(-1.1F, -2.4F, 0.5F); this.ear_right.addBox(-3.0F, -1.0F, 0.0F, 3, 2, 1, 0.0F); this.setRotateAngle(ear_right, -0.22759093446006054F, 0.091106186954104F, 1.0016444577195458F); this.arm_right_2 = new AdvancedModelBox(this, 56, 10); this.arm_right_2.mirror = true; this.arm_right_2.setRotationPoint(0.0F, 4.0F, 0.01F); this.arm_right_2.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(arm_right_2, 0.0F, 0.0F, -0.136659280431156F); this.tusk_left = new AdvancedModelBox(this, 20, 38); this.tusk_left.setRotationPoint(2.5F, 0.7F, -2.0F); this.tusk_left.addBox(-1.0F, -2.0F, -1.0F, 1, 3, 2, 0.0F); this.setRotateAngle(tusk_left, 0.0F, 0.045553093477052F, 1.1838568316277536F); this.arm_left_2 = new AdvancedModelBox(this, 56, 10); this.arm_left_2.setRotationPoint(0.0F, 4.0F, 0.01F); this.arm_left_2.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(arm_left_2, 0.0F, 0.0F, 0.136659280431156F); this.leg_right_2 = new AdvancedModelBox(this, 0, 47); this.leg_right_2.mirror = true; this.leg_right_2.setRotationPoint(0.4F, 2.5F, 1.5F); this.leg_right_2.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(leg_right_2, 0.18203784098300857F, 0.0F, -0.13962634015954636F); this.arm_left_1 = new AdvancedModelBox(this, 48, 0); this.arm_left_1.setRotationPoint(1.9F, -2.45F, -4.8F); this.arm_left_1.addBox(-1.5F, 0.0F, -2.0F, 3, 5, 4, 0.0F); this.setRotateAngle(arm_left_1, 0.045553093477052F, 0.0F, -0.136659280431156F); this.ear_left = new AdvancedModelBox(this, 16, 22); this.ear_left.setRotationPoint(1.1F, -2.4F, 0.5F); this.ear_left.addBox(0.0F, -1.0F, 0.0F, 3, 2, 1, 0.0F); this.setRotateAngle(ear_left, -0.22759093446006054F, -0.091106186954104F, -1.0016444577195458F); this.cheek_right = new AdvancedModelBox(this, 0, 0); this.cheek_right.mirror = true; this.cheek_right.setRotationPoint(-1.0F, 0.3F, -2.0F); this.cheek_right.addBox(-3.0F, -1.0F, -1.5F, 3, 2, 3, 0.0F); this.setRotateAngle(cheek_right, 0.0F, 0.0F, -0.31869712141416456F); this.head_main = new AdvancedModelBox(this, 0, 22); this.head_main.setRotationPoint(0.0F, -1.3F, -8.0F); this.head_main.addBox(-2.5F, -4.0F, -4.0F, 5, 6, 6, 0.0F); this.setRotateAngle(head_main, 0.31869712141416456F, 0.0F, 0.0F); this.eye_left = new AdvancedModelBox(this, 0, 20); this.eye_left.setRotationPoint(2.51F, -2.5F, -1.0F); this.eye_left.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.leg_left_1 = new AdvancedModelBox(this, 0, 36); this.leg_left_1.setRotationPoint(2.3F, -1.7F, 3.6F); this.leg_left_1.addBox(-2.0F, -1.0F, -2.0F, 3, 5, 4, 0.0F); this.setRotateAngle(leg_left_1, -0.136659280431156F, 0.0F, -0.14695672301792254F); this.arm_right_1 = new AdvancedModelBox(this, 48, 0); this.arm_right_1.mirror = true; this.arm_right_1.setRotationPoint(-1.9F, -2.45F, -4.8F); this.arm_right_1.addBox(-1.5F, 0.0F, -2.0F, 3, 5, 4, 0.0F); this.setRotateAngle(arm_right_1, 0.045553093477052F, 0.0F, 0.136659280431156F); this.head_mouth = new AdvancedModelBox(this, 18, 30); this.head_mouth.setRotationPoint(0.0F, 1.2F, -3.5F); this.head_mouth.addBox(-1.5F, 0.0F, -2.5F, 3, 1, 5, 0.0F); this.setRotateAngle(head_mouth, 0.091106186954104F, 0.0F, 0.0F); this.eye_right = new AdvancedModelBox(this, 0, 20); this.eye_right.setRotationPoint(-2.51F, -2.5F, -1.0F); this.eye_right.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.head_snout = new AdvancedModelBox(this, 29, 25); this.head_snout.setRotationPoint(0.0F, -0.8F, -3.0F); this.head_snout.addBox(-2.5F, -1.5F, -4.0F, 5, 3, 5, 0.0F); this.setRotateAngle(head_snout, 0.36425021489121656F, 0.0F, 0.0F); this.main_body = new AdvancedModelBox(this, 0, 0); this.main_body.setRotationPoint(0.0F, 17.0F, 0.0F); this.main_body.addBox(-3.0F, -5.0F, -8.0F, 6, 7, 14, 0.0F); this.setRotateAngle(main_body, -0.045553093477052F, 0.0F, 0.0F); this.cheek_left = new AdvancedModelBox(this, 0, 0); this.cheek_left.setRotationPoint(1.0F, 0.3F, -2.0F); this.cheek_left.addBox(0.0F, -1.0F, -1.5F, 3, 2, 3, 0.0F); this.setRotateAngle(cheek_left, 0.0F, 0.0F, 0.31869712141416456F); this.leg_left_2 = new AdvancedModelBox(this, 0, 47); this.leg_left_2.setRotationPoint(-0.4F, 2.5F, 1.5F); this.leg_left_2.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(leg_left_2, 0.18203784098300857F, 0.0F, 0.13962634015954636F); this.leg_right_1 = new AdvancedModelBox(this, 0, 36); this.leg_right_1.mirror = true; this.leg_right_1.setRotationPoint(-2.3F, -1.7F, 3.6F); this.leg_right_1.addBox(-1.0F, -1.0F, -2.0F, 3, 5, 4, 0.0F); this.setRotateAngle(leg_right_1, -0.136659280431156F, 0.0F, 0.13962634015954636F); this.shape14 = new AdvancedModelBox(this, 6, 6); this.shape14.setRotationPoint(0.0F, -5.0F, 6.0F); this.shape14.addBox(-1.5F, 0.0F, 0.0F, 3, 7, 0, 0.0F); this.setRotateAngle(shape14, 0.18203784098300857F, 0.0F, 0.0F); this.shape15 = new AdvancedModelBox(this, 34, 13); this.shape15.setRotationPoint(0.0F, -4.5F, -4.0F); this.shape15.addBox(-1.0F, -2.0F, -5.0F, 2, 2, 10, 0.0F); this.setRotateAngle(shape15, -0.045553093477052F, 0.0F, 0.0F); this.head_snout.addChild(this.tusk_right); this.head_main.addChild(this.ear_right); this.arm_right_1.addChild(this.arm_right_2); this.head_snout.addChild(this.tusk_left); this.arm_left_1.addChild(this.arm_left_2); this.leg_right_1.addChild(this.leg_right_2); this.main_body.addChild(this.arm_left_1); this.head_main.addChild(this.ear_left); this.head_main.addChild(this.cheek_right); this.main_body.addChild(this.head_main); this.head_main.addChild(this.eye_left); this.main_body.addChild(this.leg_left_1); this.main_body.addChild(this.arm_right_1); this.head_main.addChild(this.head_mouth); this.head_main.addChild(this.eye_right); this.head_main.addChild(this.head_snout); this.head_main.addChild(this.cheek_left); this.leg_left_1.addChild(this.leg_left_2); this.main_body.addChild(this.leg_right_1); this.main_body.addChild(this.shape14); this.main_body.addChild(this.shape15); animator = ModelAnimator.create(); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.main_body); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( main_body, head_main, leg_left_1, arm_left_1, shape14, shape15, arm_right_1, leg_right_1, head_snout, ear_left, head_mouth, ear_right, eye_left, cheek_right, cheek_left, eye_right, tusk_right, tusk_left, leg_left_2, arm_left_2, arm_right_2, leg_right_2 ); } void animate(IAnimatedEntity entityIn) { animator.update(entityIn); animator.setAnimation(EntityBoar.TALK); animator.startKeyframe(10); this.rotate(animator, head_mouth, 26.09F, 0, 0); this.rotate(animator, head_main, -26.09F, 0, 0); animator.endKeyframe(); animator.resetKeyframe(10); animator.setAnimation(EntityBoar.ATTACK); animator.startKeyframe(6); this.rotate(animator, head_main, 31.31F, 0, 26.08F); animator.endKeyframe(); animator.startKeyframe(4); this.rotate(animator, head_main, -26.08F, 0, -46.96F); animator.endKeyframe(); animator.resetKeyframe(4); animator.setAnimation(EntityBoar.WORK_DIG); animator.startKeyframe(6); this.rotate(animator, main_body, 13.04F, 0, 0); animator.move(head_main, 0, 2F, 1.9F); this.rotate(animator, head_main, 44.35F, 10.43F, 0); this.rotate(animator, arm_left_1, 15.65F, 0, -7.83F); this.rotate(animator, arm_left_2, -54.78F, 0, 7.83F); this.rotate(animator, arm_right_1, 15.65F, 0, 7.83F); this.rotate(animator, arm_right_2, -54.78F, 0, -7.83F); this.rotate(animator, leg_left_1, -23.48F, 0, -8); animator.move(leg_left_1, 0, 1F, 0); this.rotate(animator, leg_right_1, -23.48F, 0, 8); animator.move(leg_right_1, 0, 1F, 0); animator.endKeyframe(); for (int i = 0; i < 4; i++) { float head_angle = i % 2 == 0 ? -10.43F : 10.43F; animator.startKeyframe(8); this.rotate(animator, main_body, 13.04F, 0, 0); animator.move(head_main, 0, 2F, 1.9F); this.rotate(animator, head_main, 44.35F, head_angle, 0); this.rotate(animator, arm_left_1, 15.65F, 0, -7.83F); this.rotate(animator, arm_left_2, -54.78F, 0, 7.83F); this.rotate(animator, arm_right_1, 15.65F, 0, 7.83F); this.rotate(animator, arm_right_2, -54.78F, 0, -7.83F); this.rotate(animator, leg_left_1, -23.48F, 0, -8); animator.move(leg_left_1, 0, 1F, 0); this.rotate(animator, leg_right_1, -23.48F, 0, 8); animator.move(leg_right_1, 0, 1F, 0); animator.endKeyframe(); } animator.resetKeyframe(10); } public void setupAnim(EntityBoar boar, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); animate(boar); float globalSpeed = 1f; float globalDegree = 1f; limbSwingAmount = Math.min(limbSwingAmount, 0.4F); // Breathing Animation this.main_body.setScale((float) (1.0F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1.0F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); bob(main_body, 0.4F * globalSpeed, 0.1F, false, ageInTicks / 20, 2); bob(arm_right_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(arm_left_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_right_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_left_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); walk(head_main, 0.4f * globalSpeed, 0.03f, false, 2.4F, 0.08F, ageInTicks / 20, 2); if (boar.tickCount % 30 > 22) this.head_snout.setScale((float) (1.0F + Math.sin(ageInTicks / 6) * 0.1F + Math.sin(ageInTicks / 2) * 0.1F), (float) (1.0F + Math.sin(ageInTicks / 8) * 0.06F), 1.0F); if (boar.tickCount % 100 > 88) { swing(ear_left, 1.5f * globalSpeed, 0.6f * globalDegree, true, 0F, 0f, ageInTicks / 2.2F, limbSwingAmount); swing(ear_right, 1.5f * globalSpeed, 0.6f * globalDegree, true, 0.2F, 0f, ageInTicks / 2.2F, limbSwingAmount); } // Blinking Animation if (!boar.shouldRenderEyes()) { this.eye_right.setRotationPoint(-0.51F, -1.0F, -2.0F); this.eye_left.setRotationPoint(0.51F, -1.0F, -2.0F); } // Head Tracking Animation if (!boar.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 2, head_main); } // Pitch/Yaw handler if (boar.isInWater() && !boar.isOnGround()) { float pitch = Mth.clamp(boar.getXRot(), -20F, 20.0F) - 10; this.setRotateAngle(main_body, (float) (pitch * Math.PI / 180F), 0, 0); } // Movement Animation if (boar.canMove()) { if (boar.getCurrentSpeed() > 0.1f || boar.isAngry()) { // Running animation bob(main_body, 0.5F * globalSpeed, 0.8F, true, limbSwing, limbSwingAmount); walk(main_body, 0.5f * globalSpeed, 0.5f * globalDegree, true, 0.5F, 0f, limbSwing, limbSwingAmount); walk(head_main, 0.5f * globalSpeed, -0.5f * globalDegree, true, 0.5F, 0f, limbSwing, limbSwingAmount); flap(head_main, 0.25f * globalSpeed, -0.3f * globalDegree, true, 0.5F, 0f, limbSwing, limbSwingAmount); bob(head_main, 0.5F * globalSpeed, 0.8F, true, limbSwing, limbSwingAmount); bob(arm_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right_1, 0.5f * globalSpeed, 1.4f * globalDegree, true, 0F, 0.4f, limbSwing, limbSwingAmount); walk(arm_right_2, 0.5f * globalSpeed, 0.8f * globalDegree, true, 0.2F, 0.6f, limbSwing, limbSwingAmount); bob(arm_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left_1, 0.5f * globalSpeed, 1.4f * globalDegree, true, 0.6F, 0.4f, limbSwing, limbSwingAmount); walk(arm_left_2, 0.5f * globalSpeed, 0.8f * globalDegree, true, 0.8F, 0.6f, limbSwing, limbSwingAmount); bob(leg_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_1, 0.5f * globalSpeed, 1f * globalDegree, true, 1.4F, -0.4f, limbSwing, limbSwingAmount); walk(leg_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 1.6F, -0.6f, limbSwing, limbSwingAmount); bob(leg_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_1, 0.5f * globalSpeed, 1f * globalDegree, true, 2F, -0.4F, limbSwing, limbSwingAmount); walk(leg_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 2.2F, -0.6f, limbSwing, limbSwingAmount); flap(shape14, 0.5F * globalSpeed, 1.4F * globalDegree, false, 0, 0.2F, limbSwing, limbSwingAmount); walk(shape14, 0.5F * globalSpeed, 1.8F * globalDegree, false, 1.0F, 1.8F, limbSwing, limbSwingAmount); } else { // Walking Animation bob(main_body, 0.5F * globalSpeed, 0.8F, true, limbSwing, limbSwingAmount); bob(arm_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right_1, 0.5f * globalSpeed, globalDegree, true, 0F, 0f, limbSwing, limbSwingAmount); walk(arm_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 0.2F, 0.2f, limbSwing, limbSwingAmount); bob(arm_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left_1, 0.5f * globalSpeed, globalDegree, true, 2.4F, 0f, limbSwing, limbSwingAmount); walk(arm_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 2.6F, 0.2f, limbSwing, limbSwingAmount); bob(leg_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_1, 0.5f * globalSpeed, globalDegree, true, 1F, 0f, limbSwing, limbSwingAmount); walk(leg_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 1.2F, 0.2f, limbSwing, limbSwingAmount); bob(leg_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_1, 0.5f * globalSpeed, globalDegree, true, 3.4F, 0f, limbSwing, limbSwingAmount); walk(leg_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 3.6F, 0.2f, limbSwing, limbSwingAmount); flap(shape14, 0.5F * globalSpeed, 1.4F * globalDegree, false, 0, 0.2F, limbSwing, limbSwingAmount); swing(shape14, 0.5F * globalSpeed, 0.8F * globalDegree, false, 1.0F, 0.2F, limbSwing, limbSwingAmount); } } // Sitting Animation if (boar.sitProgress > 0) { this.progressPosition(main_body, boar.sitProgress, 0.0F, 21.60F, 0.0F, 40); this.progressRotation(main_body, boar.sitProgress, (float) Math.toRadians(-2.61F), (float) Math.toRadians(5.22F), 0, 40); this.progressRotation(head_main, boar.sitProgress, 0, (float) Math.toRadians(-23.48F), 0, 40); this.progressRotation(arm_right_1, boar.sitProgress, (float) Math.toRadians(-20.87F), 0, (float) Math.toRadians(7.83F), 40); this.progressRotation(arm_right_2, boar.sitProgress, (float) Math.toRadians(-65.22F), 0, (float) Math.toRadians(-7.83F), 40); this.progressRotation(arm_left_1, boar.sitProgress, (float) Math.toRadians(-26.09F), (float) Math.toRadians(20.87F), (float) Math.toRadians(-7.83F), 40); this.progressRotation(arm_left_2, boar.sitProgress, (float) Math.toRadians(-57.39F), 0, (float) Math.toRadians(7.83F), 40); this.progressRotation(leg_left_2, boar.sitProgress, (float) Math.toRadians(-83.48F), (float) Math.toRadians(-20.87F), (float) Math.toRadians(8.00F), 40); this.progressRotation(leg_right_2, boar.sitProgress, (float) Math.toRadians(-83.48F), (float) Math.toRadians(20.87F), (float) Math.toRadians(-8.00F), 40); } // Sleeping Animation if (boar.sleepProgress > 0) { this.progressPosition(main_body, boar.sleepProgress, 0.0F, 21F, 0.0F, 40); this.progressRotation(main_body, boar.sleepProgress, (float) Math.toRadians(20.87F), 0.0F, (float) Math.toRadians(-91.30), 40); this.progressRotation(head_main, boar.sleepProgress, (float) Math.toRadians(26.09), (float) Math.toRadians(15.65), 0, 40); this.progressRotation(arm_left_1, boar.sleepProgress, (float) Math.toRadians(5.22), 0, (float) Math.toRadians(23.48), 40); this.progressRotation(leg_left_1, boar.sleepProgress, (float) Math.toRadians(10.43), 0, (float) Math.toRadians(36.52), 40); } } }
19,960
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
MonsterSpitterLarva.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/MonsterSpitterLarva.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.relict.EntitySpitter; public class MonsterSpitterLarva extends AdvancedEntityModel<EntitySpitter> { private final AdvancedModelBox body_main; private final AdvancedModelBox back_sail; private final AdvancedModelBox head_snout; private final AdvancedModelBox arm_left_lower; private final AdvancedModelBox arm_right_lower; private final AdvancedModelBox leg_left_lower; private final AdvancedModelBox leg_right_lower; private final AdvancedModelBox head_tube; private final AdvancedModelBox arm_left_claw; private final AdvancedModelBox arm_right_claw; private final AdvancedModelBox leg_left_claw; private final AdvancedModelBox leg_right_claw; public MonsterSpitterLarva() { this.texWidth = 128; this.texHeight = 64; this.body_main = new AdvancedModelBox(this, 0, 0); this.body_main.setRotationPoint(0.0F, 23.0F, 1.0F); this.body_main.addBox(-3.5F, -5.0F, -6.0F, 7, 4, 12, 0.0F); this.arm_left_claw = new AdvancedModelBox(this, 54, 34); this.arm_left_claw.mirror = true; this.arm_left_claw.setRotationPoint(0.0F, 3.0F, -2.5F); this.arm_left_claw.addBox(-1.0F, 0.0F, -4.0F, 2, 2, 4, 0.0F); this.setRotateAngle(arm_left_claw, 1.5481070465189704F, 0.0F, 0.0F); this.head_snout = new AdvancedModelBox(this, 2, 38); this.head_snout.setRotationPoint(0.0F, -3.5F, -6.0F); this.head_snout.addBox(-2.5F, -3.0F, -4.0F, 5, 4, 5, 0.0F); this.setRotateAngle(head_snout, -0.18203784098300857F, 0.0F, 0.0F); this.head_tube = new AdvancedModelBox(this, 2, 49); this.head_tube.setRotationPoint(0.0F, -1.5F, -4.0F); this.head_tube.addBox(-1.5F, -1.5F, -6.0F, 3, 3, 6, 0.0F); this.leg_left_lower = new AdvancedModelBox(this, 58, 46); this.leg_left_lower.mirror = true; this.leg_left_lower.setRotationPoint(3.0F, -4.0F, 5.0F); this.leg_left_lower.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); this.setRotateAngle(leg_left_lower, -0.136659280431156F, -0.22759093446006054F, 0.10995574287564275F); this.arm_right_claw = new AdvancedModelBox(this, 54, 34); this.arm_right_claw.mirror = true; this.arm_right_claw.setRotationPoint(0.0F, 3.0F, -2.5F); this.arm_right_claw.addBox(-1.0F, 0.0F, -4.0F, 2, 2, 4, 0.0F); this.setRotateAngle(arm_right_claw, 1.5481070465189704F, 0.0F, 0.0F); this.leg_right_claw = new AdvancedModelBox(this, 54, 40); this.leg_right_claw.setRotationPoint(0.0F, 3.8F, -2.0F); this.leg_right_claw.addBox(-1.0F, 0.0F, -4.0F, 2, 2, 4, 0.0F); this.setRotateAngle(leg_right_claw, 1.6845917940249266F, 0.0F, 0.0F); this.leg_right_lower = new AdvancedModelBox(this, 58, 46); this.leg_right_lower.mirror = true; this.leg_right_lower.setRotationPoint(-3.0F, -4.0F, 5.0F); this.leg_right_lower.addBox(-1.5F, 0.0F, -1.5F, 3, 6, 3, 0.0F); this.setRotateAngle(leg_right_lower, -0.136659280431156F, 0.22759093446006054F, -0.10995574287564275F); this.arm_right_lower = new AdvancedModelBox(this, 42, 33); this.arm_right_lower.mirror = true; this.arm_right_lower.setRotationPoint(-3.0F, -2.0F, -2.5F); this.arm_right_lower.addBox(-1.5F, 0.0F, -1.5F, 3, 5, 3, 0.0F); this.setRotateAngle(arm_right_lower, -0.5009094953223726F, 0.0F, -0.091106186954104F); this.arm_left_lower = new AdvancedModelBox(this, 42, 33); this.arm_left_lower.mirror = true; this.arm_left_lower.setRotationPoint(3.0F, -2.0F, -2.5F); this.arm_left_lower.addBox(-1.5F, 0.0F, -1.5F, 3, 5, 3, 0.0F); this.setRotateAngle(arm_left_lower, -0.5009094953223726F, 0.0F, 0.091106186954104F); this.back_sail = new AdvancedModelBox(this, 82, 44); this.back_sail.setRotationPoint(0.0F, -3.0F, 3.0F); this.back_sail.addBox(-2.5F, -5.0F, -4.0F, 5, 5, 8, 0.0F); this.setRotateAngle(back_sail, -0.27314402793711257F, 0.0F, 0.0F); this.leg_left_claw = new AdvancedModelBox(this, 54, 40); this.leg_left_claw.setRotationPoint(0.0F, 3.8F, -2.0F); this.leg_left_claw.addBox(-1.0F, 0.0F, -4.0F, 2, 2, 4, 0.0F); this.setRotateAngle(leg_left_claw, 1.6845917940249266F, 0.0F, 0.0F); this.arm_left_lower.addChild(this.arm_left_claw); this.body_main.addChild(this.head_snout); this.head_snout.addChild(this.head_tube); this.body_main.addChild(this.leg_left_lower); this.arm_right_lower.addChild(this.arm_right_claw); this.leg_right_lower.addChild(this.leg_right_claw); this.body_main.addChild(this.leg_right_lower); this.body_main.addChild(this.arm_right_lower); this.body_main.addChild(this.arm_left_lower); this.body_main.addChild(this.back_sail); this.leg_left_lower.addChild(this.leg_left_claw); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( body_main, back_sail, leg_right_lower, arm_right_claw, leg_left_lower, arm_left_claw, arm_right_lower, arm_left_lower, head_snout, head_tube ); } public void setupAnim(EntitySpitter spitter, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); float globalSpeed = 2.4f; float globalDegree = 1f; limbSwingAmount = Math.min(0.6F, limbSwingAmount * 2); limbSwing *= 0.5F; // Model Parameters // Breathing Animation final double scaleX = Math.sin(ageInTicks / 20F); final double scaleY = Math.sin(ageInTicks / 16); this.body_main.setScale((float) (1F + scaleX * 0.08F), (float) (1F + scaleY * 0.06F), 1.0F); bob(body_main, 0.4F * globalSpeed, 0.03F, false, ageInTicks / 20, 2); bob(arm_right_lower, 0.4F * globalSpeed, 0.03F, false, -ageInTicks / 20, 2); bob(arm_left_lower, 0.4F * globalSpeed, 0.03F, false, -ageInTicks / 20, 2); bob(leg_right_lower, 0.4F * globalSpeed, 0.03F, false, -ageInTicks / 20, 2); bob(leg_left_lower, 0.4F * globalSpeed, 0.03F, false, -ageInTicks / 20, 2); // Blinking Animation // Head Tracking Animation if (!spitter.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 2, head_snout); } // Pitch/Yaw handler if (spitter.isInWater() && !spitter.isOnGround()) { limbSwing = ageInTicks / 3; limbSwingAmount = 0.5f; this.body_main.rotationPointY += 4; // Model offset to make the Big Cat "sink" in water (while not drowning) float pitch = Mth.clamp(spitter.getXRot() - 10, -25F, 25.0F); this.setRotateAngle(body_main, (float) (pitch * Math.PI / 180F), 0, 0); } // Movement Animation if (spitter.canMove()) { if (spitter.getCurrentSpeed() > 0.1f || spitter.isAngry()) { // Running animation bob(body_main, 0.5F * globalSpeed, 0.5F, false, limbSwing, limbSwingAmount); walk(body_main, 0.5f * globalSpeed, 0.5f * globalDegree, true, 0.5F, 0f, limbSwing, limbSwingAmount); bob(arm_right_lower, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right_lower, 0.5f * globalSpeed, globalDegree, true, 0F, 0f, limbSwing, limbSwingAmount); bob(arm_left_lower, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left_lower, 0.5f * globalSpeed, globalDegree, true, 0.6F, 0f, limbSwing, limbSwingAmount); bob(leg_right_lower, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_lower, 0.5f * globalSpeed, globalDegree, true, 1.4F, 0f, limbSwing, limbSwingAmount); bob(leg_left_lower, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_lower, 0.5f * globalSpeed, globalDegree, true, 2F, 0f, limbSwing, limbSwingAmount); } else { // Walking Animation bob(arm_right_lower, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right_lower, 0.5f * globalSpeed, globalDegree, true, 0F, 0f, limbSwing, limbSwingAmount); bob(arm_left_lower, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left_lower, 0.5f * globalSpeed, globalDegree, true, 2.4F, 0f, limbSwing, limbSwingAmount); bob(leg_right_lower, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_lower, 0.5f * globalSpeed, globalDegree, true, 1F, 0f, limbSwing, limbSwingAmount); bob(leg_left_lower, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_lower, 0.5f * globalSpeed, globalDegree, true, 3.4F, 0f, limbSwing, limbSwingAmount); } } // Sitting Animation if (spitter.sitProgress > 0) { this.progressPosition(body_main, spitter.sitProgress, 0.0F, 23F, 1.0F, 40); this.progressRotation(leg_left_lower, spitter.sitProgress, -1.2292353921796064F, -0.22759093446006054F, 0.045553093477052F, 40); this.progressRotation(arm_left_lower, spitter.sitProgress, -1.8668041679331349F, 0.0F, 0.10803588069844901F, 40); this.progressRotation(leg_right_lower, spitter.sitProgress, -1.2292353921796064F, 0.22759093446006054F, -0.045553093477052F, 40); this.progressRotation(arm_right_lower, spitter.sitProgress, -1.8668041679331349F, 0.0F, -0.10803588069844901F, 40); } // Sleeping Animation if (spitter.sleepProgress > 0) { this.progressPosition(body_main, spitter.sleepProgress, -4.0F, 23F, -4.0F, 40); this.progressRotation(body_main, spitter.sleepProgress, 0, 0.0F, -1.50255395F, 40); this.progressRotation(leg_left_lower, spitter.sleepProgress, -0.13665928F, 0, 0.77405352F, 40); this.progressRotation(arm_left_lower, spitter.sleepProgress, -0.5009095F, -0.09110619F, 1.0472F, 40); } } }
10,696
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelWhaleShark.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelWhaleShark.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.fish.EntityWhaleShark; public class ModelWhaleShark extends AdvancedEntityModel<EntityWhaleShark> { private final AdvancedModelBox body_main; private final AdvancedModelBox head_snout_1; private final AdvancedModelBox body_tail_1; private final AdvancedModelBox fin_pectoral_right; private final AdvancedModelBox fin_pectoral_left; private final AdvancedModelBox head_snout_2; private final AdvancedModelBox body_tail_2; private final AdvancedModelBox fin_dorsal; private final AdvancedModelBox fin_pelvic_right; private final AdvancedModelBox fin_pelvic_right_1; private final AdvancedModelBox body_tail_3; private final AdvancedModelBox fin_dorsal_2; private final AdvancedModelBox fin_anal; private final AdvancedModelBox fin_caudal_top; private final AdvancedModelBox fin_caudal_bottom; private final AdvancedModelBox head_jaw; private static AdvancedModelBox[] bodyParts_passive; public ModelWhaleShark() { this.texWidth = 128; this.texHeight = 128; this.fin_pelvic_right_1 = new AdvancedModelBox(this, 40, 102); this.fin_pelvic_right_1.setRotationPoint(3.0F, 4.5F, 5.0F); this.fin_pelvic_right_1.addBox(-1.0F, 0.0F, -3.5F, 2, 7, 7, 0.0F); this.setRotateAngle(fin_pelvic_right_1, 0.31869712141416456F, 0.0F, -1.0927506446736497F); this.head_snout_2 = new AdvancedModelBox(this, 0, 31); this.head_snout_2.mirror = true; this.head_snout_2.setRotationPoint(0.0F, 5.6F, 0.0F); this.head_snout_2.addBox(-10.0F, -4.0F, -24.0F, 20, 8, 24, 0.0F); this.setRotateAngle(head_snout_2, -0.136659280431156F, 0.0F, 0.0F);this.body_tail_3 = new AdvancedModelBox(this, 74, 0); this.body_tail_3.setRotationPoint(0.0F, 0.0F, 14.0F); this.body_tail_3.addBox(-2.0F, -3.0F, -0.5F, 4, 6, 13, 0.0F); this.setRotateAngle(body_tail_3, 0.045553093477052F, 0.0F, 0.0F); this.fin_pelvic_right = new AdvancedModelBox(this, 40, 102); this.fin_pelvic_right.mirror = true; this.fin_pelvic_right.setRotationPoint(-3.0F, 4.5F, 5.0F); this.fin_pelvic_right.addBox(-1.0F, 0.0F, -3.5F, 2, 7, 7, 0.0F); this.setRotateAngle(fin_pelvic_right, 0.31869712141416456F, 0.0F, 1.0927506446736497F); this.head_jaw = new AdvancedModelBox(this, 44, 31); this.head_jaw.setRotationPoint(0.0F, 2F, 0.0F); this.head_jaw.addBox(-9.0F, 0.0F, -24.0F, 18, 0, 24, 0.0F); this.body_tail_1 = new AdvancedModelBox(this, 58, 82); this.body_tail_1.setRotationPoint(0.0F, 1.0F, 15.0F); this.body_tail_1.addBox(-5.0F, -6.0F, 0.0F, 10, 12, 20, 0.0F); this.setRotateAngle(body_tail_1, -0.136659280431156F, 0.0F, 0.0F); this.fin_dorsal = new AdvancedModelBox(this, 0, 0); this.fin_dorsal.setRotationPoint(0.0F, -8.0F, -4.0F); this.fin_dorsal.addBox(-1.0F, -11.0F, 1.0F, 2, 15, 10, 0.0F); this.setRotateAngle(fin_dorsal, -0.4553564018453205F, 0.0F, 0.0F); this.body_tail_2 = new AdvancedModelBox(this, 0, 102); this.body_tail_2.setRotationPoint(0.0F, 0.0F, 20.0F); this.body_tail_2.addBox(-4.0F, -5.0F, -0.5F, 8, 10, 14, 0.0F); this.setRotateAngle(body_tail_2, 0.045553093477052F, 0.0F, 0.0F); this.fin_anal = new AdvancedModelBox(this, 74, 114); this.fin_anal.setRotationPoint(0.0F, 2.5F, 4.0F); this.fin_anal.addBox(-1.0F, 0.0F, -2.0F, 2, 6, 5, 0.0F); this.setRotateAngle(fin_anal, 0.8196066167365371F, 0.0F, 0.0F); this.fin_caudal_top = new AdvancedModelBox(this, 108, 0); this.fin_caudal_top.setRotationPoint(0.0F, -1.0F, 7.0F); this.fin_caudal_top.addBox(-1.0F, -24.0F, 0.0F, 2, 24, 8, 0.0F); this.setRotateAngle(fin_caudal_top, -0.8651597102135892F, 0.0F, 0.0F); this.body_main = new AdvancedModelBox(this, 0, 64); this.body_main.setRotationPoint(0.0F, 18.0F, -20.0F); this.body_main.addBox(-7.0F, -7.0F, -8.0F, 14, 14, 24, 0.0F); this.setRotateAngle(body_main, 0.045553093477052F, 0.0F, 0.0F); this.fin_pectoral_left = new AdvancedModelBox(this, 100, 70); this.fin_pectoral_left.mirror = true; this.fin_pectoral_left.setRotationPoint(3.0F, 3.2F, -7.0F); this.fin_pectoral_left.addBox(-1.0F, 0.0F, -2.0F, 2, 20, 9, 0.0F); this.setRotateAngle(fin_pectoral_left, 0.31869712141416456F, 0.0F, -1.0927506446736497F); this.fin_pectoral_right = new AdvancedModelBox(this, 100, 70); this.fin_pectoral_right.setRotationPoint(-3.0F, 3.2F, -7.0F); this.fin_pectoral_right.addBox(-1.0F, 0.0F, -2.0F, 2, 20, 9, 0.0F); this.setRotateAngle(fin_pectoral_right, 0.31869712141416456F, 0.0F, 1.0927506446736497F); this.fin_dorsal_2 = new AdvancedModelBox(this, 58, 114); this.fin_dorsal_2.setRotationPoint(0.0F, -2.5F, 5.0F); this.fin_dorsal_2.addBox(-1.0F, -6.0F, -2.0F, 2, 6, 5, 0.0F); this.setRotateAngle(fin_dorsal_2, -0.6373942428283291F, 0.0F, 0.0F); this.head_snout_1 = new AdvancedModelBox(this, 1, 1); this.head_snout_1.setRotationPoint(0.0F, -4.1F, -7.5F); this.head_snout_1.addBox(-10.0F, -3.0F, -23.8F, 20, 5, 25, 0.0F); this.setRotateAngle(head_snout_1, 0.045553093477052F, 0.0F, 0.0F); this.head_snout_1.scaleX = 1.01F; this.fin_caudal_bottom = new AdvancedModelBox(this, 108, 34); this.fin_caudal_bottom.setRotationPoint(0.0F, -8.0F, 8.0F); this.fin_caudal_bottom.addBox(-1.0F, -10.0F, 0.0F, 2, 10, 8, 0.0F); this.setRotateAngle(fin_caudal_bottom, -1.5707963267948966F, 0.0F, 0.0F); this.body_tail_1.addChild(this.fin_pelvic_right_1); this.head_snout_1.addChild(this.head_snout_2); this.body_tail_2.addChild(this.body_tail_3); this.body_tail_1.addChild(this.fin_pelvic_right); this.body_main.addChild(this.body_tail_1); this.body_tail_1.addChild(this.fin_dorsal); this.body_tail_1.addChild(this.body_tail_2); this.body_tail_2.addChild(this.fin_anal); this.body_tail_3.addChild(this.fin_caudal_top); this.body_main.addChild(this.fin_pectoral_left); this.body_main.addChild(this.fin_pectoral_right); this.body_tail_2.addChild(this.fin_dorsal_2); this.head_snout_2.addChild(this.head_jaw); this.body_main.addChild(this.head_snout_1); this.fin_caudal_top.addChild(this.fin_caudal_bottom); bodyParts_passive = new AdvancedModelBox[]{head_snout_1, body_main, body_tail_1, body_tail_2, body_tail_3}; updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of(body_main, head_snout_1, body_tail_1, fin_pectoral_right, fin_pectoral_left, head_snout_2, head_jaw, body_tail_2, fin_dorsal, fin_pelvic_right, fin_pelvic_right_1, body_tail_3, fin_dorsal_2, fin_anal, fin_caudal_top, fin_caudal_bottom ); } public void setupAnim(EntityWhaleShark whale_shark, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); float globalSpeed = 0.6f; float globalDegree = 1f; // Breathing Animation this.head_snout_1.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.08F) + 0.01F, (float) (1F + Math.sin(ageInTicks / 16) * 0.08F), 1.0F); this.head_snout_2.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.08F), (float) (1F + Math.sin(ageInTicks / 16) * 0.08F), 1.0F); // Pitch/Yaw handler if (whale_shark.isInWater()) { this.setRotateAngle(body_main, Mth.clamp(whale_shark.getXRot(), -20, 20) * ((float) Math.PI / 180F), 0, 0); } // Movement Animation float partialTicks = ageInTicks - whale_shark.tickCount; float renderYaw = (float)whale_shark.getMovementOffsets(0, partialTicks)[0]; chainSwing(bodyParts_passive, globalSpeed * 0.8F, globalDegree * 0.75F, -5, limbSwing / 4, Math.max(0.2F, limbSwingAmount)); this.body_tail_1.rotateAngleY += smartClamp((float)whale_shark.getMovementOffsets(15, partialTicks)[0] - renderYaw, -40, 40) * ((float) Math.PI / 180F); this.body_tail_2.rotateAngleY += smartClamp((float)whale_shark.getMovementOffsets(17, partialTicks)[0] - renderYaw, -40, 40) * ((float) Math.PI / 180F); this.body_main.rotateAngleZ += smartClamp((float)whale_shark.getMovementOffsets(7, partialTicks)[0] - renderYaw, -20, 20) * ((float) Math.PI / 180F); } // This wrapper handles cases where the returned MovementOffset is a large negative angle, which throws off the clamp function public float smartClamp(float angle, int min, int max) { float val = Math.abs(angle); if (val > 180) { angle = 360 - val; } return Mth.clamp(angle, min, max); } }
9,537
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelBigCat.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelBigCat.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityBigCat; public class ModelBigCat extends AdvancedEntityModel<EntityBigCat> { public AdvancedModelBox body_main; public AdvancedModelBox body_abdomen; public AdvancedModelBox head_neck; public AdvancedModelBox arm_right_upper; public AdvancedModelBox arm_left_upper; public AdvancedModelBox leg_right_upper; public AdvancedModelBox tail_1; public AdvancedModelBox leg_left_upper; public AdvancedModelBox leg_right_lower; public AdvancedModelBox leg_right_paw; public AdvancedModelBox tail_2; public AdvancedModelBox tail_3; public AdvancedModelBox tail_4; public AdvancedModelBox tail_5; public AdvancedModelBox leg_left_lower; public AdvancedModelBox leg_left_paw; public AdvancedModelBox head_main; public AdvancedModelBox eye_right; public AdvancedModelBox eye_right_1; public AdvancedModelBox head_snout; public AdvancedModelBox head_jaw; public AdvancedModelBox ear_right; public AdvancedModelBox ear_left; public AdvancedModelBox head_cheek_right; public AdvancedModelBox head_cheek_left; public AdvancedModelBox head_snout_teeth; public AdvancedModelBox arm_right_lower; public AdvancedModelBox arm_right_paw; public AdvancedModelBox arm_left_lower; public AdvancedModelBox arm_left_paw; public AdvancedModelBox teeth_right; public AdvancedModelBox teeth_left; public AdvancedModelBox neck_mane; public AdvancedModelBox teeth_down_right; public AdvancedModelBox teeth_down_left; private final ModelAnimator animator; private static AdvancedModelBox[] bodyParts_tail; private float tailX = -1; public ModelBigCat() { this.texWidth = 128; this.texHeight = 64; this.arm_left_lower = new AdvancedModelBox(this, 42, 33); this.arm_left_lower.mirror = true; this.arm_left_lower.setRotationPoint(1.0F, 7.0F, 0.5F); this.arm_left_lower.addBox(-1.5F, 0.0F, -1.5F, 3, 8, 3, 0.0F); this.setRotateAngle(arm_left_lower, -0.5009094953223726F, 0.0F, 0.091106186954104F); this.eye_right = new AdvancedModelBox(this, 19, 34); this.eye_right.setRotationPoint(-2.5F, -2.0F, -5.01F); this.eye_right.addBox(-1.0F, 0.0F, 0.0F, 2, 1, 0, 0.0F); this.eye_right_1 = new AdvancedModelBox(this, 23, 34); this.eye_right_1.setRotationPoint(2.5F, -2.0F, -5.01F); this.eye_right_1.addBox(-1.0F, 0.0F, 0.0F, 2, 1, 0, 0.0F); this.arm_left_upper = new AdvancedModelBox(this, 42, 20); this.arm_left_upper.mirror = true; this.arm_left_upper.setRotationPoint(2.0F, -2.0F, -2.5F); this.arm_left_upper.addBox(-1.0F, 0.0F, -2.5F, 4, 8, 5, 0.0F); this.setRotateAngle(arm_left_upper, 0.27314402793711257F, 0.0F, -0.091106186954104F); this.ear_left = new AdvancedModelBox(this, 20, 35); this.ear_left.mirror = true; this.ear_left.setRotationPoint(2F, -2.5F, -2.0F); this.ear_left.addBox(0.0F, -2.0F, 0.0F, 2, 2, 1, 0.0F); this.setRotateAngle(ear_left, 0.0F, -0.045553093477052F, 0.22759093446006054F); this.body_abdomen = new AdvancedModelBox(this, 40, 0); this.body_abdomen.setRotationPoint(0.0F, -1.0F, 6.0F); this.body_abdomen.addBox(-3.5F, -4.0F, 0.0F, 7, 10, 10, 0.0F); this.leg_left_paw = new AdvancedModelBox(this, 54, 40); this.leg_left_paw.setRotationPoint(0.0F, 6.8F, -1.0F); this.leg_left_paw.addBox(-2.0F, 0.0F, -2.0F, 4, 2, 4, 0.0F); this.setRotateAngle(leg_left_paw, 0.31869712141416456F, 0.0F, 0.0F); this.head_main = new AdvancedModelBox(this, 0, 34); this.head_main.setRotationPoint(0.0F, -0.5F, -4.5F); this.head_main.addBox(-3.5F, -3.0F, -5.0F, 7, 6, 5, 0.0F); this.setRotateAngle(head_main, 0.091106186954104F, 0.0F, 0.0F); this.arm_right_upper = new AdvancedModelBox(this, 42, 20); this.arm_right_upper.setRotationPoint(-2.0F, -2.0F, -2.5F); this.arm_right_upper.addBox(-3.0F, 0.0F, -2.5F, 4, 8, 5, 0.0F); this.setRotateAngle(arm_right_upper, 0.27314402793711257F, 0.0F, 0.091106186954104F); this.head_neck = new AdvancedModelBox(this, 0, 22); this.head_neck.setRotationPoint(0.0F, -1.5F, -4.5F); this.head_neck.addBox(-3.0F, -3.0F, -6.0F, 6, 6, 6, 0.0F); this.setRotateAngle(head_neck, -0.136659280431156F, 0.0F, 0.0F); this.leg_right_lower = new AdvancedModelBox(this, 58, 46); this.leg_right_lower.setRotationPoint(-1.0F, 5.5F, 3.0F); this.leg_right_lower.addBox(-1.5F, 0.0F, -1.5F, 3, 7, 3, 0.0F); this.setRotateAngle(leg_right_lower, -0.136659280431156F, 0.0F, -0.045553093477052F); this.head_cheek_left = new AdvancedModelBox(this, 28, 40); this.head_cheek_left.setRotationPoint(2.0F, 0.0F, -2.0F); this.head_cheek_left.addBox(0.0F, -2.0F, -1.0F, 3, 5, 2, 0.0F); this.setRotateAngle(head_cheek_left, 0.0F, 0.0F, 0.22759093446006054F); this.tail_1 = new AdvancedModelBox(this, 74, 0); this.tail_1.setRotationPoint(0.0F, -2.5F, 9.0F); this.tail_1.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 6, 0.0F); this.setRotateAngle(tail_1, -1.0016444577195458F, 0.0F, 0.0F); this.ear_right = new AdvancedModelBox(this, 20, 35); this.ear_right.setRotationPoint(-2F, -2.5F, -2.0F); this.ear_right.addBox(-2.0F, -2.0F, 0.0F, 2, 2, 1, 0.0F); this.setRotateAngle(ear_right, 0.0F, 0.045553093477052F, -0.22759093446006054F); this.tail_3 = new AdvancedModelBox(this, 74, 16); this.tail_3.setRotationPoint(0.0F, 0.0F, 5.5F); this.tail_3.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 6, 0.0F); this.setRotateAngle(tail_3, 0.31869712141416456F, 0.0F, 0.0F); this.tail_4 = new AdvancedModelBox(this, 74, 24); this.tail_4.setRotationPoint(0.0F, -0.1F, 5.5F); this.tail_4.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 6, 0.0F); this.setRotateAngle(tail_4, 0.6373942428283291F, 0.0F, 0.0F); this.tail_5 = new AdvancedModelBox(this, 74, 32); this.tail_5.setRotationPoint(0.0F, -0.1F, 5.5F); this.tail_5.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 6, 0.0F); this.setRotateAngle(tail_5, 0.8F, 0.0F, 0.0F); this.head_snout = new AdvancedModelBox(this, 0, 45); this.head_snout.setRotationPoint(0.0F, -1.2F, -4.0F); this.head_snout.addBox(-2.0F, 0.0F, -4.0F, 4, 3, 4, 0.0F); this.setRotateAngle(head_snout, 0.31869712141416456F, 0.0F, 0.0F); this.head_jaw = new AdvancedModelBox(this, 25, 35); this.head_jaw.setRotationPoint(0.0F, 1.9F, -3.5F); this.head_jaw.addBox(-2.0F, 0.0F, -3.5F, 4, 1, 3, 0.0F); this.setRotateAngle(head_jaw, 0.136659280431156F, 0.0F, 0.0F); this.head_jaw.scaleX = 0.95F; this.leg_left_upper = new AdvancedModelBox(this, 38, 46); this.leg_left_upper.mirror = true; this.leg_left_upper.setRotationPoint(2.0F, 0.0F, 6.0F); this.leg_left_upper.addBox(-1.0F, -2.0F, -3.0F, 4, 10, 6, 0.0F); this.setRotateAngle(leg_left_upper, -0.18203784098300857F, 0.0F, -0.045553093477052F); this.arm_left_paw = new AdvancedModelBox(this, 54, 34); this.arm_left_paw.mirror = true; this.arm_left_paw.setRotationPoint(0.0F, 7.0F, -1.0F); this.arm_left_paw.addBox(-2.0F, 0.0F, -2.0F, 4, 2, 4, 0.0F); this.setRotateAngle(arm_left_paw, 0.22759093446006054F, 0.0F, 0.0F); this.leg_right_upper = new AdvancedModelBox(this, 38, 46); this.leg_right_upper.setRotationPoint(-2.0F, 0.0F, 6.0F); this.leg_right_upper.addBox(-3.0F, -2.0F, -3.0F, 4, 10, 6, 0.0F); this.setRotateAngle(leg_right_upper, -0.18203784098300857F, 0.0F, 0.045553093477052F); this.head_snout_teeth = new AdvancedModelBox(this, 16, 45); this.head_snout_teeth.setRotationPoint(0.0F, 2.0F, 0.1F); this.head_snout_teeth.addBox(-2.0F, 0.0F, -4.0F, 4, 2, 4, 0.0F); this.arm_right_paw = new AdvancedModelBox(this, 54, 34); this.arm_right_paw.setRotationPoint(0.0F, 7.0F, -1.0F); this.arm_right_paw.addBox(-2.0F, 0.0F, -2.0F, 4, 2, 4, 0.0F); this.setRotateAngle(arm_right_paw, 0.22759093446006054F, 0.0F, 0.0F); this.leg_left_lower = new AdvancedModelBox(this, 58, 46); this.leg_left_lower.mirror = true; this.leg_left_lower.setRotationPoint(1.0F, 5.5F, 3.0F); this.leg_left_lower.addBox(-1.5F, 0.0F, -1.5F, 3, 7, 3, 0.0F); this.setRotateAngle(leg_left_lower, -0.136659280431156F, 0.0F, 0.045553093477052F); this.body_main = new AdvancedModelBox(this, 0, 0); this.body_main.setRotationPoint(0.0F, 11.0F, -4.0F); this.body_main.addBox(-4.0F, -5.0F, -6.0F, 8, 10, 12, 0.0F); this.leg_right_paw = new AdvancedModelBox(this, 54, 40); this.leg_right_paw.mirror = true; this.leg_right_paw.setRotationPoint(0.0F, 6.8F, -1.0F); this.leg_right_paw.addBox(-2.0F, 0.0F, -2.0F, 4, 2, 4, 0.0F); this.setRotateAngle(leg_right_paw, 0.31869712141416456F, 0.0F, 0.0F); this.arm_right_lower = new AdvancedModelBox(this, 42, 33); this.arm_right_lower.setRotationPoint(-1.0F, 7.0F, 0.5F); this.arm_right_lower.addBox(-1.5F, 0.0F, -1.5F, 3, 8, 3, 0.0F); this.setRotateAngle(arm_right_lower, -0.5009094953223726F, 0.0F, -0.091106186954104F); this.tail_2 = new AdvancedModelBox(this, 74, 8); this.tail_2.setRotationPoint(0.0F, -0.1F, 5.5F); this.tail_2.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 6, 0.0F); this.setRotateAngle(tail_2, -0.22759093446006054F, 0.0F, 0.0F); this.head_cheek_right = new AdvancedModelBox(this, 28, 40); this.head_cheek_right.mirror = true; this.head_cheek_right.setRotationPoint(-2.0F, 0.0F, -2.0F); this.head_cheek_right.addBox(-3.0F, -2.0F, -1.0F, 3, 5, 2, 0.0F); this.setRotateAngle(head_cheek_right, 0.0F, 0.0F, -0.22759093446006054F); this.teeth_right = new AdvancedModelBox(this, 16, 52); this.teeth_right.setRotationPoint(-1.48F, 2.4F, -2.70F); this.teeth_right.addBox(-0.5F, 0.0F, -1.0F, 1, 4, 2, 0.0F); this.setRotateAngle(teeth_right, 0.0F, 0.0F, 0.045553093477052F); this.teeth_left = new AdvancedModelBox(this, 16, 52); this.teeth_left.setRotationPoint(1.48F, 2.4F, -2.70F); this.teeth_left.addBox(-0.5F, 0.0F, -1.0F, 1, 4, 2, 0.0F); this.setRotateAngle(teeth_left, 0.0F, 0.0F, -0.045553093477052F); this.neck_mane = new AdvancedModelBox(this, 70, 44); this.neck_mane.setRotationPoint(0F, -1F, -2.60F); this.neck_mane.addBox(-5.5F, -3.5F, -4.0F, 11, 12, 8, 0.0F); this.teeth_down_right = new AdvancedModelBox(this, 22, 52); this.teeth_down_right.setRotationPoint(-1.48F, 0.8F, -2.70F); this.teeth_down_right.addBox(-0.5F, -4.0F, -1.0F, 1, 4, 2, 0.0F); this.setRotateAngle(teeth_down_right, 0.091106186954104F, 0.0F, -0.18203784098300857F); this.teeth_down_left = new AdvancedModelBox(this, 22, 52); this.teeth_down_left.setRotationPoint(1.48F, 0.8F, -2.70F); this.teeth_down_left.addBox(-0.5F, -4.0F, -1.0F, 1, 4, 2, 0.0F); this.setRotateAngle(teeth_down_left, 0.091106186954104F, 0.0F, 0.18203784098300857F); this.head_jaw.addChild(this.teeth_down_left); this.head_jaw.addChild(this.teeth_down_right); this.head_neck.addChild(this.neck_mane); this.head_snout.addChild(this.teeth_right); this.head_snout.addChild(this.teeth_left); this.arm_left_upper.addChild(this.arm_left_lower); this.head_main.addChild(this.eye_right); this.body_main.addChild(this.arm_left_upper); this.head_main.addChild(this.ear_left); this.body_main.addChild(this.body_abdomen); this.leg_left_lower.addChild(this.leg_left_paw); this.head_neck.addChild(this.head_main); this.head_main.addChild(this.eye_right_1); this.body_main.addChild(this.arm_right_upper); this.body_main.addChild(this.head_neck); this.leg_right_upper.addChild(this.leg_right_lower); this.head_main.addChild(this.head_cheek_left); this.body_abdomen.addChild(this.tail_1); this.head_main.addChild(this.ear_right); this.tail_3.addChild(this.tail_4); this.tail_4.addChild(this.tail_5); this.head_main.addChild(this.head_snout); this.head_main.addChild(this.head_jaw); this.body_abdomen.addChild(this.leg_left_upper); this.arm_left_lower.addChild(this.arm_left_paw); this.body_abdomen.addChild(this.leg_right_upper); this.head_snout.addChild(this.head_snout_teeth); this.arm_right_lower.addChild(this.arm_right_paw); this.leg_left_upper.addChild(this.leg_left_lower); this.leg_right_lower.addChild(this.leg_right_paw); this.arm_right_upper.addChild(this.arm_right_lower); this.tail_1.addChild(this.tail_2); this.head_main.addChild(this.head_cheek_right); this.tail_2.addChild(this.tail_3); bodyParts_tail = new AdvancedModelBox[]{tail_1, tail_2, tail_3, tail_4, tail_5}; animator = ModelAnimator.create(); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( body_main, body_abdomen, head_neck, arm_right_upper, arm_left_upper, leg_right_upper, tail_1, leg_left_upper, leg_right_lower, leg_right_paw, tail_2, tail_3, tail_4, leg_left_lower, leg_left_paw, head_main, eye_right, eye_right_1, head_snout, head_jaw, ear_right, ear_left, head_cheek_right, head_cheek_left, head_snout_teeth, arm_right_lower, arm_right_paw, arm_left_lower, arm_left_paw, tail_5); } private void animate(IAnimatedEntity entityIn) { EntityBigCat big_cat = (EntityBigCat) entityIn; animator.update(big_cat); animator.setAnimation(EntityBigCat.IDLE_TALK); animator.startKeyframe(10); this.rotate(animator, head_jaw, 26.09F, 0, 0); this.rotate(animator, head_main, -26.09F, 0, 0); animator.endKeyframe(); animator.resetKeyframe(10); animator.setAnimation(EntityBigCat.ATTACK_POUNCE); animator.startKeyframe(12); this.rotate(animator, body_main, -18.26F, 0, 0); animator.move(body_main, 0, -2, 0); this.rotate(animator, body_abdomen, -7.83F, 0, 0); this.rotate(animator, head_jaw, 52.17F, 0, 0); this.rotate(animator, arm_left_upper, -20.87F, 0, -20.87F); this.rotate(animator, arm_left_lower, -60F, 0, 7.83F); this.rotate(animator, arm_left_paw, 52.17F, 0, 0); animator.move(arm_left_paw, 0, 1.5F, 0); this.rotate(animator, arm_right_upper, -20.87F, 0, 20.87F); this.rotate(animator, arm_right_lower, -60F, 0, -7.83F); this.rotate(animator, arm_right_paw, 52.17F, 0, 0); animator.move(arm_right_paw, 0, 1.5F, 0); this.rotate(animator, leg_left_upper, 15.65F, 0, -2.61F); animator.move(leg_left_lower, 0, -1.5F, 0); this.rotate(animator, leg_right_upper, 15.65F, 0, 2.61F); animator.move(leg_right_lower, 0, -1.5F, 0); this.rotate(animator, tail_1, -15.65F, 0, 0); animator.endKeyframe(); animator.startKeyframe(6); this.rotate(animator, body_main, 2.61F, 0, 0); //animator.move(body_main, 0, -6, 0); this.rotate(animator, body_abdomen, -7.83F, 0, 0); this.rotate(animator, head_neck, -10.43F, -5.22F, 7.83F); this.rotate(animator, head_main, 0, 2.61F, -18.26F); this.rotate(animator, head_jaw, 52.17F, 0, 0); this.rotate(animator, arm_left_upper, -52.17F, -18.26F, -10.44F); this.rotate(animator, arm_left_lower, -60F, 0, 7.83F); this.rotate(animator, arm_left_paw, 60F, 0, 0); animator.move(arm_left_paw, 0, 1.5F, 0); this.rotate(animator, arm_right_upper, -52.17F, 18.26F, 10.44F); this.rotate(animator, arm_right_lower, -60F, 0, -7.83F); this.rotate(animator, arm_right_paw, 60F, 0, 0); animator.move(arm_right_paw, 0, 1.5F, 0); this.rotate(animator, leg_left_upper, 62.61F, 15.65F, -2.61F); this.rotate(animator, leg_left_paw, 78.26F, 0, 0); animator.move(leg_left_paw, 0, 1F, 1F); this.rotate(animator, leg_right_upper, 62.61F, -15.65F, 2.61F); this.rotate(animator, leg_right_paw, 78.26F, 0, 0); animator.move(leg_right_paw, 0, 1F, 1F); this.rotate(animator, tail_1, -15.65F, 0, 0); animator.endKeyframe(); animator.startKeyframe(10); this.rotate(animator, body_main, 23.48F, 0, 0); //animator.move(body_main, 0, -2, 0); this.rotate(animator, body_abdomen, -23.48F, 0, 0); this.rotate(animator, head_main, 0, 2.61F, -18.26F); this.rotate(animator, arm_left_upper, 5.22F, 0, -15.65F); this.rotate(animator, arm_left_lower, -60F, 0, 23.48F); animator.move(arm_left_upper, 0, 1F, 0); this.rotate(animator, arm_left_paw, 23.48F, 0, 0); this.rotate(animator, arm_right_upper, 5.22F, 0, 15.65F); this.rotate(animator, arm_right_lower, -60F, 0, -23.48F); animator.move(arm_right_upper, 0, 1F, 0); this.rotate(animator, arm_right_paw, 23.48F, 0, 0); this.rotate(animator, leg_left_upper, 2.61F, -5.22F, -10.43F); //this.rotate(animator, leg_left_paw, 78.26F, 0, 0); animator.move(leg_left_paw, 0, 1F, 1F); this.rotate(animator, leg_right_upper, 2.61F, 5.22F, 10.43F); //this.rotate(animator, leg_right_paw, 78.26F, 0, 0); animator.move(leg_right_paw, 0, 1F, 1F); this.rotate(animator, tail_1, -15.65F, 0, 0); animator.endKeyframe(); animator.startKeyframe(6); this.rotate(animator, body_main, 7.83F, 0, 0); animator.move(body_main, 0, 2, 0); this.rotate(animator, body_abdomen, -10.43F, 0, 0); this.rotate(animator, head_main, 2.61F, 7.83F, -2.61F); this.rotate(animator, arm_left_upper, 39.13F, 0, -15.65F); animator.move(arm_left_upper, 0, 3, 0); this.rotate(animator, arm_left_lower, -60F, 0, 23.48F); this.rotate(animator, arm_left_paw, 23.48F, 0, 0); this.rotate(animator, arm_right_upper, 39.13F, 0, 15.65F); animator.move(arm_right_upper, 0, 3, 0); this.rotate(animator, arm_right_lower, -60F, 0, -23.48F); this.rotate(animator, arm_right_paw, 23.48F, 0, 0); this.rotate(animator, leg_left_upper, -5.22F, 0, -2.61F); this.rotate(animator, leg_right_upper, -5.22F, 0, 2.61F); this.rotate(animator, tail_1, -15.65F, 0, 0); animator.endKeyframe(); animator.resetKeyframe(8); animator.setAnimation(EntityBigCat.ATTACK_MAUL); animator.startKeyframe(8); animator.move(body_main, 0, -0.7F, 0); this.rotate(animator, body_main, -5.22F, -10.43F, 7.83F); this.rotate(animator, body_abdomen, -5.22F, 10.43F, -7.83F); this.rotate(animator, head_main, 31.30F, -13.04F, 23.48F); animator.move(arm_right_upper, -1, -1, 0); this.rotate(animator, arm_right_upper, -78.26F, 33.91F, -10.43F); this.rotate(animator, arm_right_lower, -62.61F, -5.22F, -5.22F); animator.move(arm_right_paw, 0, 2F, 1.4F); this.rotate(animator, arm_right_paw, 164.35F, 0, 0); animator.move(arm_left_upper, 0, 0.9F, 0); this.rotate(animator, arm_left_upper, 23.48F, 10.43F, -10.43F); this.rotate(animator, leg_right_upper, -2.61F, 0, 2.61F); this.rotate(animator, leg_left_upper, -2.61F, 0, -2.61F); animator.endKeyframe(); animator.startKeyframe(6); animator.move(body_main, 0, 1.9F, 0); this.rotate(animator, body_main, 13.04F, -10.43F, 7.83F); this.rotate(animator, body_abdomen, -23.48F, 10.43F, -7.83F); this.rotate(animator, head_main, 39.13F, 7.83F, 0); this.rotate(animator, head_jaw, 33.91F, 0, 0); this.rotate(animator, head_neck, -54.78F, 0, 0); animator.move(arm_right_upper, 0, 0, -2); this.rotate(animator, arm_right_upper, -73.04F, 13.04F, -10.43F); this.rotate(animator, arm_right_lower, -13.04F, -5.22F, -5.22F); animator.move(arm_right_paw, 0, 0, -0.7F); this.rotate(animator, arm_right_paw, 117.39F, 0, 0); animator.move(arm_left_upper, 0, -1.2F, 0); this.rotate(animator, arm_left_upper, 15.65F, 10.43F, -10.43F); this.rotate(animator, arm_left_lower, -60, 0, 5.22F); this.rotate(animator, arm_left_paw, 31.30F, 0, 0); this.rotate(animator, leg_right_upper, -2.61F, 0, 2.61F); this.rotate(animator, leg_left_upper, -2.61F, 0, -2.61F); animator.endKeyframe(); animator.resetKeyframe(8); animator.setAnimation(EntityBigCat.IDLE_STRETCH); animator.startKeyframe(20); animator.move(body_main, 0, 5, 6); this.rotate(animator, body_main, 18.26F, 0, 0); this.rotate(animator, head_neck, -15.65F, 0, 0); this.rotate(animator, head_main, -7.83F, 0, 0); animator.move(body_abdomen, 0, 0, -2); this.rotate(animator, body_abdomen, 20.87F, 0, 0); animator.move(arm_left_upper, 0, -2, 0); //this.rotate(animator, arm_left_upper, -44.35F, 0, -5.22F); this.rotate(animator, arm_left_upper, -62, 0, -5.22F); this.rotate(animator, arm_left_paw, 57.39F, 0, 0); animator.move(arm_right_upper, 0, -2, 0); //this.rotate(animator, arm_right_upper, -44.35F, 0, 5.22F); this.rotate(animator, arm_right_upper, -62, 0, -5.22F); this.rotate(animator, arm_right_paw, 57.39F, 0, 0); this.rotate(animator, leg_left_upper, -39.14F, 0, 0); this.rotate(animator, leg_right_upper, -39.14F, 0, 0); animator.endKeyframe(); animator.startKeyframe(70); animator.move(body_main, 0, 5, 6); this.rotate(animator, body_main, 18.26F, 0, 0); this.rotate(animator, head_neck, -15.65F, 0, 0); this.rotate(animator, head_main, -7.83F, 0, 0); animator.move(body_abdomen, 0, 0, -2); this.rotate(animator, body_abdomen, 20.87F, 0, 0); animator.move(arm_left_upper, 0, -2, 0); //this.rotate(animator, arm_left_upper, -44.35F, 0, -5.22F); this.rotate(animator, arm_left_upper, -62, 0, -5.22F); this.rotate(animator, arm_left_paw, 57.39F, 0, 0); animator.move(arm_right_upper, 0, -2, 0); //this.rotate(animator, arm_right_upper, -44.35F, 0, 5.22F); this.rotate(animator, arm_right_upper, -62, 0, -5.22F); this.rotate(animator, arm_right_paw, 57.39F, 0, 0); this.rotate(animator, leg_left_upper, -39.14F, 0, 0); this.rotate(animator, leg_right_upper, -39.14F, 0, 0); animator.endKeyframe(); animator.resetKeyframe(20); } public void setupAnim(EntityBigCat big_cat, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); animate(big_cat); float globalSpeed = 2.4f; float globalDegree = 1f; limbSwingAmount = Math.min(0.6F, limbSwingAmount * 2); limbSwing *= 0.5F; // Model Parameters float tail_scale = big_cat.hasFluffyTail() ? 2 : 1; for (AdvancedModelBox tail_part : bodyParts_tail) { tail_part.scaleX = tail_scale; tail_part.scaleY = tail_scale; } // Breathing Animation boolean isPurring = big_cat.getAnimation() == EntityBigCat.IDLE_STRETCH && big_cat.getAnimationTick() > 20; final double scaleX = Math.sin(ageInTicks * (isPurring ? 2 : 1 / 20F)); final double scaleY = Math.sin(ageInTicks / (isPurring ? 8 : 16)); this.body_main.setScale((float) (1F + scaleX * 0.08F), (float) (1F + scaleY * 0.06F), 1.0F); this.body_abdomen.setScale((float) (1F + scaleX * 0.06F), (float) (1F + scaleY * 0.06F), 1.0F); bob(body_main, 0.4F * globalSpeed, 0.03F, false, ageInTicks / 20, 2); bob(arm_right_upper, 0.4F * globalSpeed, 0.03F, false, -ageInTicks / 20, 2); bob(arm_left_upper, 0.4F * globalSpeed, 0.03F, false, -ageInTicks / 20, 2); bob(leg_right_upper, 0.4F * globalSpeed, 0.03F, false, -ageInTicks / 20, 2); bob(leg_left_upper, 0.4F * globalSpeed, 0.03F, false, -ageInTicks / 20, 2); if (!big_cat.isSleeping()) { chainFlap(bodyParts_tail, 0.3F * globalSpeed, 0.25F * globalDegree, 0.5F, ageInTicks / 6, 2); } // Blinking Animation if (!big_cat.shouldRenderEyes()) { this.eye_right.setRotationPoint(-2.5F, -2.0F, -4.5F); this.eye_right_1.setRotationPoint(2.5F, -2.0F, -4.5F); } // Head Tracking Animation if (!big_cat.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 3, head_neck); this.faceTarget(netHeadYaw, headPitch, 3, head_main); } // Pitch/Yaw handler if (big_cat.isInWater() && !big_cat.isOnGround()) { limbSwing = ageInTicks / 3; limbSwingAmount = 0.5f; this.body_main.rotationPointY += 4; // Model offset to make the Big Cat "sink" in water (while not drowning) this.setRotateAngle(head_neck, -0.18203784098300857F, 0.0F, 0.0F); float pitch = Mth.clamp(big_cat.getXRot() - 10, -25F, 25.0F); this.setRotateAngle(body_main, (float) (pitch * Math.PI / 180F), 0, 0); } // Movement Animation float newZ = Mth.lerp(0.4F, this.tailX, this.tail_1.defaultRotationX + (float)big_cat.getCurrentSpeed() * 2); this.tail_1.rotateAngleX = newZ; this.tailX = newZ; if (big_cat.canMove()) { if (big_cat.getCurrentSpeed() > 0.1f || big_cat.isAngry()) { // Running animation bob(body_main, 0.5F * globalSpeed, 0.5F, false, limbSwing, limbSwingAmount); walk(body_main, 0.5f * globalSpeed, 0.5f * globalDegree, true, 0.5F, 0f, limbSwing, limbSwingAmount); walk(head_neck, 0.5f * globalSpeed, -0.5f * globalDegree, true, 0.5F, 0f, limbSwing, limbSwingAmount); walk(body_abdomen, 0.5f * globalSpeed, 0.3f * globalDegree, false, 0.5F, 0f, limbSwing, limbSwingAmount); bob(arm_right_upper, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right_upper, 0.5f * globalSpeed, globalDegree, true, 0F, 0f, limbSwing, limbSwingAmount); walk(arm_right_lower, 0.5f * globalSpeed, 0.6f * globalDegree, true, 0.2F, 0.2f, limbSwing, limbSwingAmount); walk(arm_right_paw, 0.5f * globalSpeed, 2f * globalDegree, false, 0.4F, 1.0f, limbSwing, limbSwingAmount); bob(arm_left_upper, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left_upper, 0.5f * globalSpeed, globalDegree, true, 0.6F, 0f, limbSwing, limbSwingAmount); walk(arm_left_lower, 0.5f * globalSpeed, 0.6f * globalDegree, true, 0.8F, 0.2f, limbSwing, limbSwingAmount); walk(arm_left_paw, 0.5f * globalSpeed, 2f * globalDegree, false, 1F, 1.0f, limbSwing, limbSwingAmount); bob(leg_right_upper, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_upper, 0.5f * globalSpeed, globalDegree, true, 1.4F, 0f, limbSwing, limbSwingAmount); walk(leg_right_lower, 0.5f * globalSpeed, 0.6f * globalDegree, true, 1.6F, 0.2f, limbSwing, limbSwingAmount); walk(leg_right_paw, 0.5f * globalSpeed, 0.8f * globalDegree, false, 1.8F, 0.0f, limbSwing, limbSwingAmount); bob(leg_left_upper, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_upper, 0.5f * globalSpeed, globalDegree, true, 2F, 0f, limbSwing, limbSwingAmount); walk(leg_left_lower, 0.5f * globalSpeed, 0.6f * globalDegree, true, 2.2F, 0.2f, limbSwing, limbSwingAmount); walk(leg_left_paw, 0.5f * globalSpeed, 0.8f * globalDegree, false, 2.4F, 0.0f, limbSwing, limbSwingAmount); } else { // Walking Animation bob(arm_right_upper, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right_upper, 0.5f * globalSpeed, globalDegree, true, 0F, 0f, limbSwing, limbSwingAmount); walk(arm_right_lower, 0.5f * globalSpeed, 0.6f * globalDegree, true, 0.2F, 0.2f, limbSwing, limbSwingAmount); walk(arm_right_paw, 0.5f * globalSpeed, 2f * globalDegree, false, 0.4F, 1.0f, limbSwing, limbSwingAmount); bob(arm_left_upper, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left_upper, 0.5f * globalSpeed, globalDegree, true, 2.4F, 0f, limbSwing, limbSwingAmount); walk(arm_left_lower, 0.5f * globalSpeed, 0.6f * globalDegree, true, 2.6F, 0.2f, limbSwing, limbSwingAmount); walk(arm_left_paw, 0.5f * globalSpeed, 2f * globalDegree, false, 2.8F, 1.0f, limbSwing, limbSwingAmount); bob(leg_right_upper, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_upper, 0.5f * globalSpeed, globalDegree, true, 1F, 0f, limbSwing, limbSwingAmount); walk(leg_right_lower, 0.5f * globalSpeed, 0.6f * globalDegree, true, 1.2F, 0.2f, limbSwing, limbSwingAmount); walk(leg_right_paw, 0.5f * globalSpeed, 0.8f * globalDegree, false, 1.4F, 0.0f, limbSwing, limbSwingAmount); bob(leg_left_upper, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_upper, 0.5f * globalSpeed, globalDegree, true, 3.4F, 0f, limbSwing, limbSwingAmount); walk(leg_left_lower, 0.5f * globalSpeed, 0.6f * globalDegree, true, 3.6F, 0.2f, limbSwing, limbSwingAmount); walk(leg_left_paw, 0.5f * globalSpeed, 0.8f * globalDegree, false, 3.8F, 0.0f, limbSwing, limbSwingAmount); } } if (big_cat.aggroProgress != 0) { // Aggro/Stalking animation this.head_snout_teeth.scaleX = 1.05F; this.progressPosition(body_main, big_cat.aggroProgress, 0, 14, -4, 40); this.progressPosition(arm_right_upper, big_cat.aggroProgress, -2, -4, -2.5F, 40); this.progressPosition(arm_left_upper, big_cat.aggroProgress, 2, -4, -2.5F, 40); this.progressPosition(leg_right_upper, big_cat.aggroProgress, -2, -2, 6, 40); this.progressPosition(leg_left_upper, big_cat.aggroProgress, 2, -2, 6, 40); this.progressRotation(head_neck, big_cat.aggroProgress, 0.22759093446006054F, 0, 0, 40); this.progressRotation(head_main, big_cat.aggroProgress, -0.22759093446006054F, 0, 0, 40); this.progressRotation(ear_right, big_cat.aggroProgress, -0.22759093446006054F, 0.045553093477052F, -0.22759093446006054F, 40); this.progressRotation(ear_left, big_cat.aggroProgress, -0.22759093446006054F, -0.045553093477052F, 0.22759093446006054F, 40); this.progressRotation(tail_1, big_cat.aggroProgress, (float) Math.toRadians(-44.35), 0, 0, 40); } else { this.head_snout_teeth.scaleX = 0.9F; } // Sitting Animation if (big_cat.sitProgress > 0) { this.progressPosition(body_main, big_cat.sitProgress, 0.0F, 18.5F, 1.0F, 40); this.progressPosition(leg_left_upper, big_cat.sitProgress, 2.0F, -2.0F, 6F, 40); this.progressPosition(leg_left_paw, big_cat.sitProgress, 0.0F, 7.8F, 0.0F, 40); this.progressPosition(arm_left_paw, big_cat.sitProgress, 0.0F, 7.8F, 0.0F, 40); this.progressPosition(leg_right_upper, big_cat.sitProgress, -2.0F, -2.0F, 6F, 40); this.progressPosition(leg_right_paw, big_cat.sitProgress, 0.0F, 7.8F, 0.0F, 40); this.progressPosition(arm_right_paw, big_cat.sitProgress, 0.0F, 7.8F, 0.0F, 40); this.progressRotation(head_neck, big_cat.sitProgress, -0.5462880558742251F, 0.0F, 0.0F, 40); this.progressRotation(leg_left_upper, big_cat.sitProgress, -0.27314402793711257F, -0.0F, -0.045553093477052F, 40); this.progressRotation(leg_left_lower, big_cat.sitProgress, -1.2292353921796064F, -0.22759093446006054F, 0.045553093477052F, 40); this.progressRotation(leg_left_paw, big_cat.sitProgress, 1.5481070465189704F, 0.0F, 0.0F, 40); this.progressRotation(arm_left_upper, big_cat.sitProgress, 0.27314402793711207F, -6.200655107570901E-17F, -0.24361070658773F, 40); this.progressRotation(arm_left_lower, big_cat.sitProgress, -1.8668041679331349F, 0.0F, 0.10803588069844901F, 40); this.progressRotation(arm_left_paw, big_cat.sitProgress, 1.593485607070823F, -0.18203784098300857F, 0.0F, 40); this.progressRotation(leg_right_upper, big_cat.sitProgress, -0.27314402793711257F, -0.0F, 0.045553093477052F, 40); this.progressRotation(leg_right_lower, big_cat.sitProgress, -1.2292353921796064F, 0.22759093446006054F, -0.045553093477052F, 40); this.progressRotation(leg_right_paw, big_cat.sitProgress, 1.5481070465189704F, 0.0F, 0.0F, 40); this.progressRotation(arm_right_upper, big_cat.sitProgress, 0.27314402793711207F, 6.200655107570901E-17F, 0.24361070658773F, 40); this.progressRotation(arm_right_lower, big_cat.sitProgress, -1.8668041679331349F, 0.0F, -0.10803588069844901F, 40); this.progressRotation(arm_right_paw, big_cat.sitProgress, 1.593485607070823F, 0.18203784098300857F, 0.0F, 40); this.progressRotation(tail_1, big_cat.sitProgress, -1.0471975511965976F, 0.0F, 0.0F, 40); this.progressRotation(tail_2, big_cat.sitProgress, 0.5918411493512771F, 0.0F, 0.0F, 40); } // Sleeping Animation if (big_cat.sleepProgress > 0) { this.progressPosition(body_main, big_cat.sleepProgress, -4.0F, 19F, -4.0F, 40); this.progressRotation(body_main, big_cat.sleepProgress, 0, 0.0F, -1.50255395F, 40); this.progressRotation(body_abdomen, big_cat.sleepProgress, -0.455356402F, -0.0F, -0, 40); this.progressRotation(leg_right_upper, big_cat.sleepProgress, -0.500909495F , -0.0F, 0.045553093477052F, 40); this.progressRotation(leg_left_lower, big_cat.sleepProgress, -0.13665928F, 0, 0.77405352F, 40); this.progressRotation(head_neck, big_cat.sleepProgress, 0.27314402793711207F, 0.22759093446006054F, 0.0F, 40); this.progressRotation(head_main, big_cat.sleepProgress, 0.4553564F, 0, 0.0F, 40); this.progressRotation(arm_right_upper, big_cat.sleepProgress, -0.27314402793711207F, 0, 0.09110619F, 40); this.progressRotation(arm_left_lower, big_cat.sleepProgress, -0.5009095F, -0.09110619F, 1.0472F, 40); } } }
35,701
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelBearCub.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelBearCub.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityBear; public class ModelBearCub extends AdvancedEntityModel<EntityBear> { private final AdvancedModelBox body_main; private final AdvancedModelBox body_buttocks; private final AdvancedModelBox head_face; private final AdvancedModelBox arm_right; private final AdvancedModelBox arm_left; private final AdvancedModelBox leg_left; private final AdvancedModelBox leg_right; private final AdvancedModelBox head_snout; private final AdvancedModelBox ear_left; private final AdvancedModelBox ear_right; private final AdvancedModelBox eye_left; private final AdvancedModelBox eye_right; public ModelBearCub() { this.texWidth = 128; this.texHeight = 64; this.arm_right = new AdvancedModelBox(this, 85, 53); this.arm_right.setRotationPoint(-2.5F, -1.0F, -1.0F); this.arm_right.addBox(-1.5F, 0.0F, -1.5F, 3, 8, 3, 0.0F); this.body_buttocks = new AdvancedModelBox(this, 98, 50); this.body_buttocks.setRotationPoint(0.0F, 0.75F, 6.0F); this.body_buttocks.addBox(-3.5F, -3.5F, -3.5F, 7, 7, 7, 0.0F); this.setRotateAngle(body_buttocks, -0.136659280431156F, 0.0F, 0.0F); this.ear_left = new AdvancedModelBox(this, 14, 55); this.ear_left.mirror = true; this.ear_left.setRotationPoint(2.5F, -2.5F, -2.5F); this.ear_left.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 1, 0.0F); this.setRotateAngle(ear_left, -0.31869712141416456F, -0.31869712141416456F, 0.7285004297824331F); this.ear_right = new AdvancedModelBox(this, 14, 55); this.ear_right.setRotationPoint(-2.5F, -2.5F, -2.5F); this.ear_right.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 1, 0.0F); this.setRotateAngle(ear_right, -0.31869712141416456F, 0.31869712141416456F, -0.7285004297824331F); this.arm_left = new AdvancedModelBox(this, 85, 53); this.arm_left.mirror = true; this.arm_left.setRotationPoint(2.5F, -1.0F, -1.0F); this.arm_left.addBox(-1.5F, 0.0F, -1.5F, 3, 8, 3, 0.0F); this.leg_left = new AdvancedModelBox(this, 85, 53); this.leg_left.mirror = true; this.leg_left.setRotationPoint(2.8F, -1.9F, 1.0F); this.leg_left.addBox(-1.5F, 0.0F, -1.5F, 3, 8, 3, 0.0F); this.setRotateAngle(leg_left, 0.136659280431156F, 0.0F, 0.0F); this.body_main = new AdvancedModelBox(this, 81, 41); this.body_main.setRotationPoint(0.0F, 17.0F, -2.0F); this.body_main.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6, 0.0F); this.eye_right = new AdvancedModelBox(this, 20, 55); this.eye_right.setRotationPoint(-0.51F, 0.0F, -3.01F); this.eye_right.addBox(-2.0F, -0.5F, -1.0F, 2, 1, 1, 0.0F); this.head_snout = new AdvancedModelBox(this, 18, 58); this.head_snout.setRotationPoint(0.0F, 1.0F, -1.3F); this.head_snout.addBox(-1.5F, -2.0F, -5.0F, 3, 3, 3, 0.0F); this.setRotateAngle(head_snout, 0.091106186954104F, 0.0F, 0.0F); this.leg_right = new AdvancedModelBox(this, 85, 53); this.leg_right.setRotationPoint(-2.8F, -1.9F, 1.0F); this.leg_right.addBox(-1.5F, 0.0F, -1.5F, 3, 8, 3, 0.0F); this.setRotateAngle(leg_right, 0.136659280431156F, 0.0F, 0.0F); this.eye_left = new AdvancedModelBox(this, 20, 55); this.eye_left.mirror = true; this.eye_left.setRotationPoint(0.51F, 0.0F, -3.01F); this.eye_left.addBox(0.0F, -0.5F, -1.0F, 2, 1, 1, 0.0F); this.head_face = new AdvancedModelBox(this, 0, 55); this.head_face.setRotationPoint(0.0F, -1.5F, -2.5F); this.head_face.addBox(-2.5F, -2.5F, -4.0F, 5, 5, 4, 0.0F); this.setRotateAngle(head_face, 0.18203784098300857F, 0.0F, 0.0F); this.body_main.addChild(this.arm_right); this.body_main.addChild(this.body_buttocks); this.head_face.addChild(this.ear_left); this.head_face.addChild(this.ear_right); this.body_main.addChild(this.arm_left); this.body_buttocks.addChild(this.leg_left); this.head_face.addChild(this.eye_right); this.head_face.addChild(this.head_snout); this.body_buttocks.addChild(this.leg_right); this.head_face.addChild(this.eye_left); this.body_main.addChild(this.head_face); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of(body_main, body_buttocks, head_face, arm_right, arm_left, leg_left, leg_right, head_snout, ear_left, ear_right, eye_left, eye_right ); } public void setupAnim(EntityBear bear, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); // Breathing Animation this.body_main.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.body_buttocks.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); bob(body_main, 0.4F * 1.5f, 0.03F, false, ageInTicks / 20, 2); bob(arm_right, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(arm_left, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(leg_right, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(leg_left, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); // Blinking Animation if (!bear.shouldRenderEyes()) { this.eye_right.setRotationPoint(-0.49F, 0, -2F); this.eye_left.setRotationPoint(0.49F, 0, -2F); } // Head Tracking Animation this.faceTarget(netHeadYaw, headPitch, 1, head_face); // Movement Animation if (bear.canMove()) { this.arm_right.rotateAngleX = Mth.cos(limbSwing * 0.5F) * 1.4F * limbSwingAmount; this.arm_left.rotateAngleX = Mth.cos(limbSwing * 0.5F + (float)Math.PI) * 1.4F * limbSwingAmount; this.leg_right.rotateAngleX = Mth.cos(limbSwing * 0.5F + (float)Math.PI) * 1.4F * limbSwingAmount; this.leg_left.rotateAngleX = Mth.cos(limbSwing * 0.5F) * 1.4F * limbSwingAmount; } // Sitting Animation if (bear.sitProgress > 0) { this.progressRotation(body_main, bear.sitProgress, -0.5462880558742251F, 0.0F, 0.0F, 40); this.progressRotation(body_buttocks, bear.sitProgress, -0.7285004297824331F, 0.0F, 0.0F, 40); this.progressRotation(arm_left, bear.sitProgress, 0.18203784098300857F, 0.0F, 0.0F, 40); this.progressRotation(arm_right, bear.sitProgress, 0.18203784098300857F, 0.0F, 0.0F, 40); this.progressRotation(head_face, bear.sitProgress, 0.36425021489121656F, 0.0F, 0.0F, 40); this.progressRotation(leg_right, bear.sitProgress, -0.045553093477052F, 0.0F, 0.22759093446006054F, 40); this.progressRotation(leg_left, bear.sitProgress, -0.045553093477052F, 0.0F, -0.22759093446006054F, 40); this.progressPosition(body_main, bear.sitProgress, 0.0F, 17.5F, -1.0F, 40); this.progressPosition(body_buttocks, bear.sitProgress, 0.0F, 2.0F, 3.5F, 40); } // Sleeping Animation else if (bear.sleepProgress > 0) { this.progressRotation(body_buttocks, bear.sleepProgress, -0.136659280431156F, 0.0F, 0.0F, 40); this.progressRotation(leg_right, bear.sleepProgress, 1.5025539530419183F, -0.40980330836826856F, 0.0F, 40); this.progressRotation(leg_left, bear.sleepProgress, 1.5025539530419183F, 0.40980330836826856F, 0.0F, 40); this.progressRotation(arm_left, bear.sleepProgress, -1.3658946726107624F, -0.36425021489121656F, 0.0F, 40); this.progressRotation(arm_right, bear.sleepProgress, -1.3658946726107624F, 0.36425021489121656F, 0.0F, 40); this.progressPosition(body_main, bear.sleepProgress, 0.0F, 22.0F, -2.0F, 40); this.progressPosition(body_buttocks, bear.sleepProgress, 0.0F, 0.0F, 6.0F, 40); this.progressPosition(head_face, bear.sleepProgress, 0.0F, -0.5F, -2.5F, 40); this.progressPosition(arm_right, bear.sleepProgress, -2.5F, 0.0F, -1.0F, 40); this.progressPosition(arm_left, bear.sleepProgress, 2.5F, 0.0F, -1.0F, 40); this.progressPosition(leg_right, bear.sleepProgress, -2.8F, 0.0F, 1.0F, 40); this.progressPosition(leg_left, bear.sleepProgress, 2.8F, 0.0F, 1.0F, 40); } } }
9,040
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelTriggerfish.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelTriggerfish.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import untamedwilds.entity.fish.EntityTriggerfish; import untamedwilds.util.EntityUtils; public class ModelTriggerfish extends AdvancedEntityModel<EntityTriggerfish> { private final AdvancedModelBox main_body; private final AdvancedModelBox body_tail; private final AdvancedModelBox fin_trigger; private final AdvancedModelBox head_main; private final AdvancedModelBox fin_anal; private final AdvancedModelBox fin_dorsal_2; private final AdvancedModelBox fin_caudal; private final AdvancedModelBox fin_pectoral_left; private final AdvancedModelBox fin_pectoral_right; private final AdvancedModelBox head_jaw; public ModelTriggerfish() { this.texWidth = 32; this.texHeight = 32; this.main_body = new AdvancedModelBox(this, 0, 0); this.main_body.setRotationPoint(0.0F, 19.9F, 0.0F); this.main_body.addBox(-1.51F, -3.5F, -3.5F, 3, 7, 7, 0.0F); this.fin_pectoral_right = new AdvancedModelBox(this, 12, 21); this.fin_pectoral_right.setRotationPoint(-1.5F, 1.5F, -1.0F); this.fin_pectoral_right.addBox(0.0F, -2.0F, 0.0F, 0, 4, 3, 0.0F); this.setRotateAngle(fin_pectoral_right, -0.6373942428283291F, -0.36425021489121656F, 0.18203784098300857F); this.head_jaw = new AdvancedModelBox(this, 14, 14); this.head_jaw.setRotationPoint(0.0F, 3.0F, -5.0F); this.head_jaw.addBox(-1.5F, -4.0F, 0.0F, 3, 4, 1, 0.0F); this.head_jaw.scaleX = 1.1F; this.fin_anal = new AdvancedModelBox(this, 20, 20); this.fin_anal.setRotationPoint(0.0F, 1.5F, -0.4F); this.fin_anal.addBox(0.0F, 0.0F, -3.0F, 0, 6, 6, 0.0F); this.setRotateAngle(fin_anal, 0.5009094953223726F, 0.0F, 0.0F); this.body_tail = new AdvancedModelBox(this, 13, 0); this.body_tail.setRotationPoint(0.0F, 0.0F, 2.5F); this.body_tail.addBox(-1.0F, -1.5F, 0.0F, 2, 3, 3, 0.0F); this.fin_pectoral_left = new AdvancedModelBox(this, 12, 21); this.fin_pectoral_left.setRotationPoint(1.5F, 1.5F, -1.0F); this.fin_pectoral_left.addBox(0.0F, -2.0F, 0.0F, 0, 4, 3, 0.0F); this.setRotateAngle(fin_pectoral_left, -0.6373942428283291F, 0.36425021489121656F, -0.18203784098300857F); this.fin_caudal = new AdvancedModelBox(this, 0, 20); this.fin_caudal.setRotationPoint(0.0F, 0.0F, 1.7F); this.fin_caudal.addBox(0.0F, 0.0F, 0.0F, 0, 6, 6, 0.0F); this.setRotateAngle(fin_caudal, 0.7853981633974483F, 0.0F, 0.0F); this.fin_dorsal_2 = new AdvancedModelBox(this, 20, 14); this.fin_dorsal_2.setRotationPoint(0.0F, -1.5F, -0.1F); this.fin_dorsal_2.addBox(0.0F, -6.0F, -3.0F, 0, 6, 6, 0.0F); this.setRotateAngle(fin_dorsal_2, -0.36425021489121656F, 0.0F, 0.0F); this.fin_trigger = new AdvancedModelBox(this, 0, 20); this.fin_trigger.setRotationPoint(0.0F, -3.0F, -3.0F); this.fin_trigger.addBox(0.0F, -3.0F, 0.0F, 0, 3, 3, 0.0F); this.setRotateAngle(fin_trigger, -1.4570008595648662F, 0.0F, 0.0F); this.head_main = new AdvancedModelBox(this, 0, 14); this.head_main.setRotationPoint(0.0F, -2.1F, -2.1F); this.head_main.addBox(-1.5F, -2.0F, -4.0F, 3, 5, 4, 0.0F); this.setRotateAngle(head_main, 0.7853981633974483F, 0.0F, 0.0F); this.head_main.scaleX = 1.1F; this.head_main.addChild(this.fin_pectoral_right); this.head_main.addChild(this.head_jaw); this.body_tail.addChild(this.fin_anal); this.main_body.addChild(this.body_tail); this.head_main.addChild(this.fin_pectoral_left); this.body_tail.addChild(this.fin_caudal); this.body_tail.addChild(this.fin_dorsal_2); this.main_body.addChild(this.fin_trigger); this.main_body.addChild(this.head_main); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.main_body); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( main_body, body_tail, fin_trigger, head_main, fin_anal, fin_dorsal_2, fin_caudal, fin_pectoral_left, fin_pectoral_right, head_jaw ); } public void setupAnim(EntityTriggerfish triggerfish, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { float f = ageInTicks - (float)triggerfish.tickCount / 10; resetToDefaultPose(); float globalSpeed = 0.5f; float globalDegree = 1f; if (!triggerfish.isInWater()) { //this.main_body.defaultPositionY += 20; this.setRotateAngle(main_body, 0, 0, (float)Math.toRadians(90D)); } else { this.setRotateAngle(main_body, triggerfish.getXRot() * ((float) Math.PI / 180F), 0, 0); //this.setRotateAngle(main_body, netHeadYaw * 2 * ((float)Math.PI / 180F), headPitch * 2 * ((float)Math.PI / 180F), 0); } AdvancedModelBox[] bodyParts = new AdvancedModelBox[]{main_body, body_tail, fin_caudal}; chainSwing(bodyParts, globalSpeed, globalDegree * 1.1f, -5, limbSwing, limbSwingAmount); if (!EntityUtils.hasFullHealth(triggerfish) || triggerfish.isAngry()) { this.setRotateAngle(fin_trigger, -0.4F, 0, 0); } chainSwing(bodyParts, globalSpeed * 0.4F, globalDegree, -5, limbSwing, 0.6F); flap(fin_pectoral_left, globalSpeed, globalDegree * 0.8f, true, 0, 0.2f, f / 4, 1F); swing(fin_pectoral_left, globalSpeed, globalDegree * 0.8f, false, 0, 0.2f, f / 4, 0.6F); flap(fin_pectoral_right, globalSpeed, globalDegree * 0.8f, false, 0, 0.2f, f / 4, 1F); swing(fin_pectoral_right, globalSpeed, globalDegree * 0.8f, true, 0, 0.2f, f / 4, 0.6F); flap(fin_dorsal_2, globalSpeed * 0.8f, globalDegree * 0.6f, true, 0, 0, Math.max(f / 6, limbSwing), 1F); flap(fin_anal, globalSpeed * 0.8f, globalDegree * 0.6f, false, 0, 0, Math.max(f / 6, limbSwing), 1F); } }
6,424
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelFootballFish.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelFootballFish.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import untamedwilds.entity.fish.EntityFootballFish; public class ModelFootballFish extends AdvancedEntityModel<EntityFootballFish> { public AdvancedModelBox main_body; public AdvancedModelBox head_jaw; public AdvancedModelBox head_fin_left; public AdvancedModelBox head_fin_right; public AdvancedModelBox body_tail; public AdvancedModelBox body_bait; public AdvancedModelBox tail_fin; public AdvancedModelBox tail_top; public AdvancedModelBox tail_bottom; public AdvancedModelBox attached_male; public ModelFootballFish() { this.texWidth = 32; this.texHeight = 32; this.head_fin_right = new AdvancedModelBox(this, 0, 0); this.head_fin_right.mirror = true; this.head_fin_right.setRotationPoint(-3.5F, 0.0F, 0.0F); this.head_fin_right.addBox(0.0F, -1.5F, 0.0F, 0, 3, 3, 0.0F); this.setRotateAngle(head_fin_right, -0.045553093477052F, -0.22759093446006054F, 0.0F); this.body_bait = new AdvancedModelBox(this, 16, 10); this.body_bait.setRotationPoint(0.0F, -3.0F, -2.0F); this.body_bait.addBox(0.0F, -5.0F, -2.5F, 0, 5, 5, 0.0F); this.body_tail = new AdvancedModelBox(this, 0, 27); this.body_tail.setRotationPoint(0.0F, 0.0F, 4.0F); this.body_tail.addBox(-1.5F, -1.5F, 0.0F, 3, 3, 2, 0.0F); this.setRotateAngle(body_tail, -0.22759093446006054F, 0.0F, 0.0F); this.tail_top = new AdvancedModelBox(this, 13, 21); this.tail_top.setRotationPoint(0.0F, -1.1F, 1.0F); this.tail_top.addBox(0.0F, -1.5F, -0.5F, 0, 3, 3, 0.0F); this.setRotateAngle(tail_top, 1.1838568316277536F, 0.0F, 0.0F); this.head_jaw = new AdvancedModelBox(this, 0, 15); this.head_jaw.setRotationPoint(0.0F, 2.0F, -3.0F); this.head_jaw.addBox(-2.5F, -4.0F, -1.0F, 5, 4, 2, 0.0F); this.setRotateAngle(head_jaw, 0.36425021489121656F, 0.0F, 0.0F); this.head_fin_left = new AdvancedModelBox(this, 0, 0); this.head_fin_left.setRotationPoint(3.5F, 0.0F, 0.0F); this.head_fin_left.addBox(0.0F, -1.5F, 0.0F, 0, 3, 3, 0.0F); this.setRotateAngle(head_fin_left, -0.045553093477052F, 0.22759093446006054F, 0.0F); this.tail_bottom = new AdvancedModelBox(this, 13, 21); this.tail_bottom.setRotationPoint(0.0F, 1.1F, 1.0F); this.tail_bottom.addBox(0.0F, -1.5F, -0.5F, 0, 3, 3, 0.0F); this.setRotateAngle(tail_bottom, -1.1838568316277536F, 0.0F, 0.0F); this.main_body = new AdvancedModelBox(this, 0, 0); this.main_body.setRotationPoint(0.0F, 21.0F, 0.0F); this.main_body.addBox(-3.5F, -3.5F, -3.5F, 7, 7, 8, 0.0F); this.setRotateAngle(main_body, 0.22759093446006054F, 0.0F, 0.0F); this.tail_fin = new AdvancedModelBox(this, 10, 24); this.tail_fin.setRotationPoint(0.0F, 0.0F, 2.0F); this.tail_fin.addBox(0.0F, -1.5F, 0.0F, 0, 3, 3, 0.0F); this.attached_male = new AdvancedModelBox(this, 6, 4); this.attached_male.setRotationPoint(0.0F, 0.0F, 2.0F); this.attached_male.addBox(0.0F, 0.0F, 0.0F, 0, 3, 1, 0.0F); this.setRotateAngle(attached_male, 0.36425021489121656F, 0.0F, 0.0F); this.main_body.addChild(this.head_fin_right); this.main_body.addChild(this.body_bait); this.main_body.addChild(this.body_tail); this.body_tail.addChild(this.tail_top); this.main_body.addChild(this.head_jaw); this.main_body.addChild(this.head_fin_left); this.body_tail.addChild(this.tail_bottom); this.body_tail.addChild(this.tail_fin); this.main_body.addChild(this.attached_male); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(main_body); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( main_body, head_jaw, head_fin_left, head_fin_right, body_tail, body_bait, tail_fin, tail_top, tail_bottom, attached_male ); } public void setupAnim(EntityFootballFish football_fish, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { float f = ageInTicks - (float)football_fish.tickCount / 10; resetToDefaultPose(); if (!football_fish.isInWater()) { main_body.defaultPositionY = 20; this.setRotateAngle(main_body, 0, 0, (float)Math.toRadians(90D)); } else { this.setRotateAngle(main_body, netHeadYaw * 2 * ((float)Math.PI / 180F), headPitch * 2 * ((float)Math.PI / 180F), 0); } float globalSpeed = 0.6f; float globalDegree = 0.6f; if (football_fish.hasAttachedMale()) { this.attached_male.setRotationPoint(0.0F, 3.0F, -2F); } // Movement Animation AdvancedModelBox[] bodyParts = new AdvancedModelBox[]{body_tail, tail_fin}; chainSwing(bodyParts, globalSpeed * 0.4F, globalDegree, -5, f, 0.6F); walk(head_jaw, globalSpeed, globalDegree * 0.2f, false, 0.2F, 0.2f, ageInTicks / 6, 0.6F); flap(head_fin_left, globalSpeed, globalDegree * 0.8f, true, 0, 0.2f, f / 6, 1F); swing(head_fin_left, globalSpeed, globalDegree * 0.8f, false, 0, 0.2f, f / 6, 0.6F); flap(head_fin_right, globalSpeed, globalDegree * 0.8f, false, 0, 0.2f, f / 6, 1F); swing(head_fin_right, globalSpeed, globalDegree * 0.8f, true, 0, 0.2f, f / 6, 0.6F); } }
5,893
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelShark.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelShark.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.fish.EntityShark; public class ModelShark extends AdvancedEntityModel<EntityShark> { private final AdvancedModelBox body_main; private final AdvancedModelBox head_snout; private final AdvancedModelBox body_tail_1; private final AdvancedModelBox fin_dorsal; private final AdvancedModelBox fin_right; private final AdvancedModelBox fin_left; private final AdvancedModelBox head_face_1; private final AdvancedModelBox head_jaw; private final AdvancedModelBox head_face_teeth; private final AdvancedModelBox head_hammer; private final AdvancedModelBox head_jaw_teeth; private final AdvancedModelBox body_tail_2; private final AdvancedModelBox fin_pelvic_left; private final AdvancedModelBox fin_pelvic_right; private final AdvancedModelBox body_tail_3; private final AdvancedModelBox fin_what_top; private final AdvancedModelBox fin_what_bottom; private final AdvancedModelBox fin_caudal; private final AdvancedModelBox fin_caudal_2; private final AdvancedModelBox head_nose; private final ModelAnimator animator; private static AdvancedModelBox[] bodyParts_passive; private static AdvancedModelBox[] bodyParts_angry; public ModelShark() { this.texWidth = 128; this.texHeight = 64; this.head_hammer = new AdvancedModelBox(this, 0, 56); this.head_hammer.setRotationPoint(0.0F, -0.3F, -6.2F); this.head_hammer.addBox(-8.0F, -1.5F, -2.0F, 16, 3, 5, 0.0F); this.setRotateAngle(head_hammer, -0.091106186954104F, 0.0F, 0.0F); this.head_jaw = new AdvancedModelBox(this, 26, 23); this.head_jaw.setRotationPoint(0.0F, 2.0F, -6.5F); this.head_jaw.addBox(-3.0F, 0.0F, -5.0F, 6, 2, 5, 0.0F); this.setRotateAngle(head_jaw, -0.13665928043115597F, 0.0F, 0.0F); this.head_snout = new AdvancedModelBox(this, 0, 23); this.head_snout.setRotationPoint(0.0F, -0.9F, -7.0F); this.head_snout.addBox(-4.5F, -3.0F, -7.0F, 9, 7, 7, 0.0F); this.setRotateAngle(head_snout, 0.0911061869541028F, -5.270556841435265E-16F, 3.1003275537854504E-16F); this.head_jaw_teeth = new AdvancedModelBox(this, 26, 38); this.head_jaw_teeth.setRotationPoint(0.0F, -1.0F, 0.0F); this.head_jaw_teeth.addBox(-3.0F, -1.0F, -5.0F, 6, 2, 5, 0.0F); this.head_jaw.scaleX = 1.1F; this.body_tail_1 = new AdvancedModelBox(this, 44, 4); this.body_tail_1.setRotationPoint(0.0F, -0.6F, 5.5F); this.body_tail_1.addBox(-3.0F, -3.0F, 0.0F, 6, 7, 10, 0.0F); this.setRotateAngle(body_tail_1, -0.136659280431156F, 0.0F, 0.0F); this.fin_left = new AdvancedModelBox(this, 50, 22); this.fin_left.mirror = true; this.fin_left.setRotationPoint(3.0F, 2.5F, -5.0F); this.fin_left.addBox(-0.5F, 0.0F, -2.0F, 1, 10, 6, 0.0F); this.setRotateAngle(fin_left, 0.31869712141416456F, 0.0F, -1.0927506446736497F); this.fin_dorsal = new AdvancedModelBox(this, 66, 22); this.fin_dorsal.setRotationPoint(0.0F, -3.3F, 0.0F); this.fin_dorsal.addBox(-0.5F, -9.0F, -2.0F, 1, 10, 6, 0.0F); this.setRotateAngle(fin_dorsal, -0.40980330836826856F, 0.0F, 0.0F); this.fin_what_bottom = new AdvancedModelBox(this, 0, 6); this.fin_what_bottom.setRotationPoint(0.0F, 1.5F, 5.0F); this.fin_what_bottom.addBox(-0.5F, 0.0F, -2.0F, 1, 3, 3, 0.0F); this.setRotateAngle(fin_what_bottom, 0.5009094953223726F, 0.0F, 0.0F); this.head_face_1 = new AdvancedModelBox(this, 0, 37); this.head_face_1.setRotationPoint(0.0F, 0.3F, -6.0F); this.head_face_1.addBox(-4.0F, -3.0F, -8.0F, 8, 5, 8, 0.0F); this.setRotateAngle(head_face_1, 0.045553093477051866F, 0.0F, 0.0F); this.head_nose = new AdvancedModelBox(this, 42, 49); this.head_nose.setRotationPoint(0.0F, -1.3F, -7.0F); this.head_nose.addBox(-2.5F, -1.5F, -12.0F, 5, 3, 12, 0.0F); this.setRotateAngle(head_nose, -0.18203784F, 0.0F, 0.0F); this.fin_caudal = new AdvancedModelBox(this, 96, 0); this.fin_caudal.setRotationPoint(0.0F, -1.1F, 5.4F); this.fin_caudal.addBox(-0.5F, -10.0F, -3.0F, 1, 11, 5, 0.0F); this.setRotateAngle(fin_caudal, -0.5918411493512771F, 0.0F, 0.0F); this.body_tail_2 = new AdvancedModelBox(this, 76, 6); this.body_tail_2.setRotationPoint(0.0F, 0.0F, 10.0F); this.body_tail_2.addBox(-2.0F, -2.5F, -0.5F, 4, 5, 10, 0.0F); this.setRotateAngle(body_tail_2, -0.045553093477052F, 0.0F, 0.0F); this.body_tail_3 = new AdvancedModelBox(this, 30, 0); this.body_tail_3.setRotationPoint(0.0F, 0.0F, 10.0F); this.body_tail_3.addBox(-1.5F, -2.0F, -0.5F, 3, 3, 8, 0.0F); this.setRotateAngle(body_tail_3, 0.136659280431156F, 0.0F, 0.0F); this.fin_what_top = new AdvancedModelBox(this, 0, 0); this.fin_what_top.setRotationPoint(0.0F, -1.5F, 3.0F); this.fin_what_top.addBox(-0.5F, -3.0F, -2.0F, 1, 3, 3, 0.0F); this.setRotateAngle(fin_what_top, -0.5009094953223726F, 0.0F, 0.0F); this.fin_caudal_2 = new AdvancedModelBox(this, 68, 0); this.fin_caudal_2.setRotationPoint(0.0F, 4.2F, 6.8F); this.fin_caudal_2.addBox(-0.5F, -4.0F, -5.0F, 1, 4, 7, 0.0F); this.setRotateAngle(fin_caudal_2, -0.7740535232594852F, 0.0F, 0.0F); this.fin_pelvic_right = new AdvancedModelBox(this, 36, 30); this.fin_pelvic_right.setRotationPoint(-2.3F, 3.0F, 7.7F); this.fin_pelvic_right.addBox(-0.5F, 0.0F, -0.8F, 1, 3, 3, 0.0F); this.setRotateAngle(fin_pelvic_right, 0.31869712141416456F, 0.0F, 1.0927506446736497F); this.body_main = new AdvancedModelBox(this, 0, 0); this.body_main.setRotationPoint(0.0F, 17.0F, 6.0F); this.body_main.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 14, 0.0F); this.setRotateAngle(body_main, 0.045553093477052F, 0.0F, 0.0F); this.fin_pelvic_left = new AdvancedModelBox(this, 36, 30); this.fin_pelvic_left.mirror = true; this.fin_pelvic_left.setRotationPoint(2.3F, 3.0F, 7.7F); this.fin_pelvic_left.addBox(-0.5F, 0.0F, -0.8F, 1, 3, 3, 0.0F); this.setRotateAngle(fin_pelvic_left, 0.31869712141416456F, 0.0F, -1.0927506446736497F); this.fin_right = new AdvancedModelBox(this, 50, 22); this.fin_right.setRotationPoint(-3.0F, 2.5F, -5.0F); this.fin_right.addBox(-0.5F, 0.0F, -2.0F, 1, 10, 6, 0.0F); this.setRotateAngle(fin_right, 0.31869712141416456F, 0.0F, 1.0927506446736497F); this.head_face_teeth = new AdvancedModelBox(this, 28, 46); this.head_face_teeth.setRotationPoint(0.0F, 3.0F, 0.0F); this.head_face_teeth.addBox(-3.0F, -1.0F, -5.0F, 6, 2, 5, 0.0F); this.head_face_1.addChild(this.head_hammer); this.head_snout.addChild(this.head_jaw); this.body_main.addChild(this.head_snout); this.head_jaw.addChild(this.head_jaw_teeth); this.body_main.addChild(this.body_tail_1); this.body_main.addChild(this.fin_left); this.body_main.addChild(this.fin_dorsal); this.body_tail_2.addChild(this.fin_what_bottom); this.head_snout.addChild(this.head_face_1); this.body_tail_3.addChild(this.fin_caudal); this.body_tail_1.addChild(this.body_tail_2); this.body_tail_2.addChild(this.body_tail_3); this.body_tail_2.addChild(this.fin_what_top); this.body_tail_3.addChild(this.fin_caudal_2); this.body_tail_1.addChild(this.fin_pelvic_right); this.body_tail_1.addChild(this.fin_pelvic_left); this.body_main.addChild(this.fin_right); this.head_face_1.addChild(this.head_face_teeth); this.head_face_1.addChild(this.head_nose); bodyParts_passive = new AdvancedModelBox[]{head_snout, body_main, body_tail_1, body_tail_2, body_tail_3}; bodyParts_angry = new AdvancedModelBox[]{body_main, body_tail_1, body_tail_2, body_tail_3}; animator = ModelAnimator.create(); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of(body_main, head_snout, body_tail_1, fin_dorsal, fin_right, fin_left, head_face_1, head_jaw, head_face_teeth, head_hammer, head_jaw_teeth, body_tail_2, fin_pelvic_left, fin_pelvic_right, body_tail_3, fin_what_top, fin_what_bottom, fin_caudal, fin_caudal_2, head_nose ); } private void animate(IAnimatedEntity entityIn) { animator.update(entityIn); animator.setAnimation(EntityShark.ATTACK_THRASH); animator.startKeyframe(5); this.rotate(animator, head_snout, -5.22F, 15.65F, -20.87F); this.rotate(animator, head_jaw, 57.39F, 0, 0); this.rotate(animator, head_face_1, -44.35F, 0, 0); animator.endKeyframe(); animator.startKeyframe(5); this.rotate(animator, head_snout, -5.22F, -5.22F, 10.43F); this.rotate(animator, head_jaw, 57.39F, 0, 0); this.rotate(animator, head_face_1, -44.35F, 0, 0); animator.endKeyframe(); animator.resetKeyframe(5); } public void setupAnim(EntityShark shark, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); animate(shark); float globalSpeed = 0.6f; float globalDegree = 1f; // Model Parameters float shortFins = shark.hasShortFins() ? 0.5F : 1; this.fin_left.scaleY = shortFins; this.fin_right.scaleY = shortFins; this.fin_dorsal.scaleY = shortFins; // Breathing Animation this.head_snout.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.08F), (float) (1F + Math.sin(ageInTicks / 16) * 0.08F), 1.0F); // Pitch/Yaw handler if (shark.isInWater()) { this.setRotateAngle(body_main, shark.getXRot() * ((float) Math.PI / 180F), 0, 0); } // Movement Animation if (!shark.isAngry()) chainSwing(bodyParts_passive, globalSpeed * 0.8F, globalDegree, -5, limbSwing / 3, Math.max(0.3F, limbSwingAmount)); else chainSwing(bodyParts_angry, globalSpeed, globalDegree / 1.5F, -4, limbSwing / 3, Math.max(0.3F, limbSwingAmount)); float partialTicks = ageInTicks - shark.tickCount; float renderYaw = (float)shark.getMovementOffsets(0, partialTicks)[0]; this.body_tail_1.rotateAngleY += smartClamp((float)shark.getMovementOffsets(15, partialTicks)[0] - renderYaw, -40, 40) * ((float) Math.PI / 180F); this.body_tail_2.rotateAngleY += smartClamp((float)shark.getMovementOffsets(17, partialTicks)[0] - renderYaw, -40, 40) * ((float) Math.PI / 180F); this.body_main.rotateAngleZ += smartClamp((float)shark.getMovementOffsets(7, partialTicks)[0] - renderYaw, -20, 20) * ((float) Math.PI / 180F); } // This wrapper handles cases where the returned MovementOffset is a large negative angle, which throws off the clamp function public float smartClamp(float angle, int min, int max) { float val = Math.abs(angle); if (val > 180) { angle = 360 - val; } return Mth.clamp(angle, min, max); } }
11,844
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelAardvark.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelAardvark.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityAardvark; public class ModelAardvark extends AdvancedEntityModel<EntityAardvark> { public AdvancedModelBox body_main; public AdvancedModelBox head_neck; public AdvancedModelBox arm_left_1; public AdvancedModelBox body_booty; public AdvancedModelBox arm_right_1; public AdvancedModelBox hair; public AdvancedModelBox head_head; public AdvancedModelBox head_ear_left; public AdvancedModelBox head_ear_right; public AdvancedModelBox head_snout; public AdvancedModelBox eye_left; public AdvancedModelBox eye_right; public AdvancedModelBox arm_left_2; public AdvancedModelBox leg_left_1; public AdvancedModelBox body_tail_1; public AdvancedModelBox leg_right_1; public AdvancedModelBox leg_left_2; public AdvancedModelBox body_tail_2; public AdvancedModelBox body_tail_3; public AdvancedModelBox leg_right_2; public AdvancedModelBox arm_right_2; private final ModelAnimator animator; public ModelAardvark() { this.texWidth = 64; this.texHeight = 32; this.leg_right_1 = new AdvancedModelBox(this, 46, 15); this.leg_right_1.mirror = true; this.leg_right_1.setRotationPoint(0.0F, -0.2F, 5.6F); this.leg_right_1.addBox(-4.0F, -1.0F, -2.0F, 4, 5, 4, 0.0F); this.setRotateAngle(leg_right_1, -0.136659280431156F, 0.0F, 0.13962634015954636F); this.body_tail_2 = new AdvancedModelBox(this, 14, 17); this.body_tail_2.setRotationPoint(0.0F, 0.0F, 3.5F); this.body_tail_2.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 6, 0.0F); this.setRotateAngle(body_tail_2, -0.22759093446006054F, 0.0F, 0.0F); this.body_booty = new AdvancedModelBox(this, 28, 0); this.body_booty.setRotationPoint(0.0F, 0.0F, 2.0F); this.body_booty.addBox(-3.0F, -4.0F, 0.0F, 6, 6, 8, 0.0F); this.setRotateAngle(body_booty, -0.4553564018453205F, 0.0F, 0.0F); this.body_tail_3 = new AdvancedModelBox(this, 14, 17); this.body_tail_3.setRotationPoint(0.0F, 0.4F, 5.3F); this.body_tail_3.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 6, 0.0F); this.setRotateAngle(body_tail_3, 0.8651597102135892F, 0.0F, 0.0F); this.body_tail_3.scaleX = 0.7F; this.leg_left_1 = new AdvancedModelBox(this, 46, 15); this.leg_left_1.setRotationPoint(0.0F, -0.2F, 5.6F); this.leg_left_1.addBox(0.0F, -1.0F, -2.0F, 4, 5, 4, 0.0F); this.setRotateAngle(leg_left_1, -0.136659280431156F, 0.0F, -0.13962634015954636F); this.leg_right_2 = new AdvancedModelBox(this, 46, 24); this.leg_right_2.mirror = true; this.leg_right_2.setRotationPoint(-2.5F, 3.1F, 1.2F); this.leg_right_2.addBox(-1.0F, 0.0F, -1.0F, 2, 4, 2, 0.0F); this.setRotateAngle(leg_right_2, 0.22759093446006054F, 0.0F, -0.13962634015954636F); this.head_ear_left = new AdvancedModelBox(this, 0, 21); this.head_ear_left.setRotationPoint(1.0F, -1.0F, -1.0F); this.head_ear_left.addBox(-1.0F, -4.0F, 0.0F, 2, 4, 1, 0.0F); this.setRotateAngle(head_ear_left, -0.091106186954104F, -0.091106186954104F, 0.8651597102135892F); this.arm_right_2 = new AdvancedModelBox(this, 30, 23); this.arm_right_2.mirror = true; this.arm_right_2.setRotationPoint(0.0F, 3.5F, 0.01F); this.arm_right_2.addBox(-1.0F, 0.0F, -1.0F, 2, 4, 2, 0.0F); this.setRotateAngle(arm_right_2, 0.0F, 0.0F, -0.136659280431156F); this.head_head = new AdvancedModelBox(this, 2, 22); this.head_head.setRotationPoint(0.0F, -1.0F, -2.5F); this.head_head.addBox(-1.5F, -2.0F, -4.0F, 3, 3, 4, 0.0F); this.setRotateAngle(head_head, 0.8196066167365371F, 0.0F, 0.0F); this.body_tail_1 = new AdvancedModelBox(this, 0, 13); this.body_tail_1.setRotationPoint(0.0F, -1.0F, 7.0F); this.body_tail_1.addBox(-2.0F, -2.0F, 0.0F, 4, 4, 4, 0.0F); this.setRotateAngle(body_tail_1, -0.5462880558742251F, 0.0F, 0.0F); this.hair = new AdvancedModelBox(this, 34, 18); this.hair.setRotationPoint(0.0F, 2.2F, 4.0F); this.hair.addBox(0.0F, 0.0F, -6.0F, 0, 2, 12, 0.0F); this.setRotateAngle(hair, -0.31869712141416456F, 0.0F, 0.0F); this.head_snout = new AdvancedModelBox(this, 16, 26); this.head_snout.setRotationPoint(0.0F, -1.0F, -4.0F); this.head_snout.addBox(-1.5F, -1.0F, -4.0F, 3, 2, 4, 0.0F); this.arm_right_1 = new AdvancedModelBox(this, 28, 15); this.arm_right_1.mirror = true; this.arm_right_1.setRotationPoint(-1.5F, -0.75F, 0.2F); this.arm_right_1.addBox(-1.5F, 0.0F, -1.5F, 3, 4, 3, 0.0F); this.setRotateAngle(arm_right_1, -0.36425021489121656F, 0.0F, 0.136659280431156F); this.eye_right = new AdvancedModelBox(this, 0, 27); this.eye_right.mirror = true; this.eye_right.setRotationPoint(-1.51F, -1.0F, -3.0F); this.eye_right.addBox(0.0F, -1.0F, -1.0F, 0, 1, 2, 0.0F); this.eye_left = new AdvancedModelBox(this, 0, 27); this.eye_left.setRotationPoint(1.51F, -1.0F, -3.0F); this.eye_left.addBox(0.0F, -1.0F, -1.0F, 0, 1, 2, 0.0F); this.head_neck = new AdvancedModelBox(this, 20, 0); this.head_neck.setRotationPoint(0.0F, -1.0F, -1.0F); this.head_neck.addBox(-1.5F, -2.0F, -4.0F, 3, 3, 4, 0.0F); this.setRotateAngle(head_neck, -0.5462880558742251F, 0.0F, 0.0F); this.head_neck.scaleX = 0.99F; this.arm_left_2 = new AdvancedModelBox(this, 30, 23); this.arm_left_2.setRotationPoint(0.0F, 3.5F, 0.01F); this.arm_left_2.addBox(-1.0F, 0.0F, -1.0F, 2, 4, 2, 0.0F); this.setRotateAngle(arm_left_2, 0.0F, 0.0F, 0.136659280431156F); this.leg_left_2 = new AdvancedModelBox(this, 46, 24); this.leg_left_2.setRotationPoint(2.5F, 3.1F, 1.2F); this.leg_left_2.addBox(-1.0F, 0.0F, -1.0F, 2, 4, 2, 0.0F); this.setRotateAngle(leg_left_2, 0.22759093446006054F, 0.0F, 0.13962634015954636F); this.arm_left_1 = new AdvancedModelBox(this, 28, 15); this.arm_left_1.setRotationPoint(1.5F, -0.75F, 0.2F); this.arm_left_1.addBox(-1.5F, 0.0F, -1.5F, 3, 4, 3, 0.0F); this.setRotateAngle(arm_left_1, -0.36425021489121656F, 0.0F, -0.136659280431156F); this.head_ear_right = new AdvancedModelBox(this, 0, 21); this.head_ear_right.mirror = true; this.head_ear_right.setRotationPoint(-1.0F, -1.0F, -1.0F); this.head_ear_right.addBox(-1.0F, -4.0F, 0.0F, 2, 4, 1, 0.0F); this.setRotateAngle(head_ear_right, -0.091106186954104F, 0.091106186954104F, -0.8651597102135892F); this.body_main = new AdvancedModelBox(this, 0, 1); this.body_main.setRotationPoint(0.0F, 17.6F, -5.0F); this.body_main.addBox(-2.5F, -3.3F, -2.0F, 5, 5, 6, 0.0F); this.setRotateAngle(body_main, 0.36425021489121656F, 0.0F, 0.0F); this.body_booty.addChild(this.leg_right_1); this.body_tail_1.addChild(this.body_tail_2); this.head_head.addChild(this.eye_right); this.body_main.addChild(this.body_booty); this.body_tail_2.addChild(this.body_tail_3); this.body_booty.addChild(this.leg_left_1); this.leg_right_1.addChild(this.leg_right_2); this.head_head.addChild(this.head_ear_left); this.arm_right_1.addChild(this.arm_right_2); this.head_neck.addChild(this.head_head); this.body_booty.addChild(this.body_tail_1); this.body_main.addChild(this.hair); this.head_head.addChild(this.head_snout); this.body_main.addChild(this.arm_right_1); this.head_head.addChild(this.eye_left); this.body_main.addChild(this.head_neck); this.arm_left_1.addChild(this.arm_left_2); this.leg_left_1.addChild(this.leg_left_2); this.body_main.addChild(this.arm_left_1); this.head_head.addChild(this.head_ear_right); animator = ModelAnimator.create(); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of(body_main, head_neck, arm_left_1, body_booty, arm_right_1, hair, head_head, head_ear_left, head_ear_right, head_snout, eye_left, eye_right, arm_left_2, leg_left_1, body_tail_1, leg_right_1, leg_left_2, body_tail_2, body_tail_3, leg_right_2, arm_right_2); } private void animate(IAnimatedEntity entityIn) { animator.update(entityIn); animator.setAnimation(EntityAardvark.WORK_DIG); animator.startKeyframe(6); animator.move(body_main, 0, 0, 1.5F); this.rotate(animator, body_main, 31.30F, 0, 0); animator.move(body_booty, 0, -0.2F, -0.3F); this.rotate(animator, body_booty, -39.13F, 0, 0); this.rotate(animator, head_neck, 7.83F, 0, 0); this.rotate(animator, arm_left_1, -46.96F, -10.43F, -18.26F); animator.endKeyframe(); for (int i = 0; i < 10; i++) { AdvancedModelBox limb = i % 2 == 0 ? arm_right_1 : arm_left_1; animator.startKeyframe(6); animator.move(body_main, 0, 0, 1.5F); this.rotate(animator, body_main, 31.30F, 0, 0); animator.move(body_booty, 0, -0.2F, -0.3F); this.rotate(animator, body_booty, -39.13F, 0, 0); this.rotate(animator, head_neck, 7.83F, 0, 0); this.rotate(animator, limb, -46.96F, -10.43F, -18.26F); // Forwards animator.endKeyframe(); } animator.resetKeyframe(10); animator.setAnimation(EntityAardvark.ATTACK); animator.startKeyframe(6); animator.move(body_main, 0, -4.6F, 0); this.rotate(animator, body_main, -26.09F, 0, 0); this.rotate(animator, body_booty, -33.91F, 0, 0); animator.move(leg_right_1, 0, -1, -1); this.rotate(animator, leg_right_1, 46.96F, 0, 0); animator.move(leg_left_1, 0, -1, -1); this.rotate(animator, leg_left_1, 46.96F, 0, 0); animator.move(body_tail_1, 0, -1, -2); this.rotate(animator, body_tail_1, 23.48F, 0, 0); this.rotate(animator, arm_left_1, -46.96F, -10.43F, -18.26F); animator.endKeyframe(); for (int i = 0; i < 3; i++) { AdvancedModelBox limb = i % 2 == 0 ? arm_right_1 : arm_left_1; animator.startKeyframe(3); animator.move(body_main, 0, -4.6F, 0); this.rotate(animator, body_main, -26.09F, 0, 0); this.rotate(animator, body_booty, -33.91F, 0, 0); animator.move(leg_right_1, 0, -1, -1); this.rotate(animator, leg_right_1, 46.96F, 0, 0); animator.move(leg_left_1, 0, -1, -1); this.rotate(animator, leg_left_1, 46.96F, 0, 0); animator.move(body_tail_1, 0, -1, -2); this.rotate(animator, body_tail_1, 23.48F, 0, 0); this.rotate(animator, limb, -46.96F, -10.43F, -18.26F); // Forwards animator.endKeyframe(); } animator.resetKeyframe(3); } public void setupAnim(EntityAardvark aardvark, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); animate(aardvark); float globalSpeed = 1f; float globalDegree = 1f; limbSwingAmount = Math.min(limbSwingAmount, 0.4F); // Breathing Animation this.body_main.setScale((float) (1.0F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1.0F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.body_booty.setScale((float) (1.0F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1.0F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); bob(body_main, 0.4F * globalSpeed, 0.1F, false, ageInTicks / 20, 2); bob(arm_right_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(arm_left_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_right_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_left_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); walk(head_neck, 0.4f * globalSpeed, 0.03f, false, 2.4F, 0.08F, ageInTicks / 20, 2); walk(head_head, 0.4f * globalSpeed, 0.03f, false, 2.8F, 0.06F, ageInTicks / 20, 2); this.head_snout.setScale((float) (1.0F + Math.sin(ageInTicks / 6) * 0.08F + Math.sin(ageInTicks / 2) * 0.1F), (float) (1.0F + Math.sin(ageInTicks / 8) * 0.04F), 1.0F); // Blinking Animation if (!aardvark.shouldRenderEyes()) { this.eye_right.setRotationPoint(-0.51F, -1.0F, -3.0F); this.eye_left.setRotationPoint(0.51F, -1.0F, -3.0F); } // Head Tracking Animation if (!aardvark.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 3, head_neck); this.faceTarget(netHeadYaw, headPitch, 3, head_head); } // Pitch/Yaw handler if (aardvark.isInWater() && !aardvark.isOnGround()) { float pitch = Mth.clamp(aardvark.getXRot(), -20F, 20.0F) - 10; this.setRotateAngle(body_main, (float) (pitch * Math.PI / 180F), 0, 0); } // Movement Animation if (aardvark.canMove()) { if (aardvark.getCurrentSpeed() > 0.1f || aardvark.isAngry()) { // Running animation bob(body_main, 0.5F * globalSpeed, 0.5F, false, limbSwing, limbSwingAmount); walk(body_main, 0.5f * globalSpeed, 0.5f * globalDegree, true, 0.5F, 0f, limbSwing, limbSwingAmount); walk(head_neck, 0.5f * globalSpeed, -0.5f * globalDegree, true, 0.5F, 0f, limbSwing, limbSwingAmount); walk(body_booty, 0.5f * globalSpeed, 0.3f * globalDegree, false, 0.5F, 0f, limbSwing, limbSwingAmount); bob(arm_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right_1, 0.5f * globalSpeed, 1f * globalDegree, true, 0F, 0f, limbSwing, limbSwingAmount); walk(arm_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 0.2F, 0.2f, limbSwing, limbSwingAmount); bob(arm_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left_1, 0.5f * globalSpeed, 1f * globalDegree, true, 0.6F, 0f, limbSwing, limbSwingAmount); walk(arm_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 0.8F, 0.2f, limbSwing, limbSwingAmount); bob(leg_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_1, 0.5f * globalSpeed, 1f * globalDegree, true, 1.4F, 0f, limbSwing, limbSwingAmount); walk(leg_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 1.6F, 0.2f, limbSwing, limbSwingAmount); bob(leg_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_1, 0.5f * globalSpeed, 1f * globalDegree, true, 2F, 0f, limbSwing, limbSwingAmount); walk(leg_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 2.2F, 0.2f, limbSwing, limbSwingAmount); } else { // Walking Animation bob(arm_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right_1, 0.5f * globalSpeed, globalDegree, true, 0F, 0f, limbSwing, limbSwingAmount); walk(arm_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 0.2F, 0.2f, limbSwing, limbSwingAmount); bob(arm_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left_1, 0.5f * globalSpeed, globalDegree, true, 2.4F, 0f, limbSwing, limbSwingAmount); walk(arm_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 2.6F, 0.2f, limbSwing, limbSwingAmount); bob(leg_right_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_1, 0.5f * globalSpeed, globalDegree, true, 1F, 0f, limbSwing, limbSwingAmount); walk(leg_right_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 1.2F, 0.2f, limbSwing, limbSwingAmount); bob(leg_left_1, 0.5F * globalSpeed, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_1, 0.5f * globalSpeed, globalDegree, true, 3.4F, 0f, limbSwing, limbSwingAmount); walk(leg_left_2, 0.5f * globalSpeed, 0.6f * globalDegree, true, 3.6F, 0.2f, limbSwing, limbSwingAmount); } } // Sleeping Animation if (aardvark.sleepProgress > 0) { this.progressPosition(body_main, aardvark.sleepProgress, -3.0F, 21F, -5.0F, 40); this.progressRotation(body_main, aardvark.sleepProgress, (float)Math.toRadians(20.87F), 0.0F, (float)Math.toRadians(-91.30), 40); this.progressRotation(head_neck, aardvark.sleepProgress, (float)Math.toRadians(26.09), (float)Math.toRadians(15.65), 0, 40); this.progressRotation(arm_left_1, aardvark.sleepProgress, (float)Math.toRadians(5.22), 0, (float)Math.toRadians(23.48), 40); this.progressRotation(leg_left_1, aardvark.sleepProgress, (float)Math.toRadians(10.43), 0, (float)Math.toRadians(36.52), 40); this.progressRotation(body_tail_1, aardvark.sleepProgress, (float)Math.toRadians(-31.30), 0, (float)Math.toRadians(23.48), 40); this.progressRotation(body_tail_2, aardvark.sleepProgress, (float)Math.toRadians(-39.13), 0, (float)Math.toRadians(-10.43), 40); this.progressRotation(body_tail_3, aardvark.sleepProgress, (float)Math.toRadians(-52.17), 0, (float)Math.toRadians(23.48), 40); } else { flap(body_tail_1, 0.4f * globalSpeed, 0.2f * globalDegree, true, 0F, 0f, ageInTicks / 6, 2); flap(body_tail_2, 0.4f * globalSpeed, 0.2f * globalDegree, true, 0.5F, 0f, ageInTicks / 6, 2); flap(body_tail_3, 0.4f * globalSpeed, 0.2f * globalDegree, true, 1.0F, 0f, ageInTicks / 6, 2); } } }
18,522
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelBisonCalf.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelBisonCalf.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityBison; public class ModelBisonCalf extends AdvancedEntityModel<EntityBison> { public AdvancedModelBox body_main; public AdvancedModelBox leg_left_thigh; public AdvancedModelBox leg_right_thigh; public AdvancedModelBox tail; public AdvancedModelBox head_neck; public AdvancedModelBox arm_right_1; public AdvancedModelBox arm_left_1; public AdvancedModelBox leg_left_calf; public AdvancedModelBox leg_right_calf; public AdvancedModelBox head_main; public AdvancedModelBox head_ear_right; public AdvancedModelBox head_ear_left; public AdvancedModelBox eye_left; public AdvancedModelBox eye_right; public AdvancedModelBox arm_right_2; public AdvancedModelBox arm_left_2; public ModelBisonCalf() { this.texWidth = 128; this.texHeight = 64; this.head_neck = new AdvancedModelBox(this, 16, 15); this.head_neck.setRotationPoint(0.0F, -1.0F, -4.5F); this.head_neck.addBox(-2.0F, -3.5F, -6.0F, 4, 6, 5, 0.0F); this.setRotateAngle(head_neck, -0.22759093446006054F, 0.0F, 0.0F); this.leg_right_calf = new AdvancedModelBox(this, 86, 28); this.leg_right_calf.mirror = true; this.leg_right_calf.setRotationPoint(-0.01F, 2.5F, 1.5F); this.leg_right_calf.addBox(-1.5F, 0.0F, -1.0F, 3, 8, 3, 0.0F); this.arm_right_1 = new AdvancedModelBox(this, 0, 0); this.arm_right_1.mirror = true; this.arm_right_1.setRotationPoint(-2.0F, 0.0F, -5.5F); this.arm_right_1.addBox(-1.5F, 0.0F, -2.0F, 3, 7, 4, 0.0F); this.setRotateAngle(arm_right_1, 0.136659280431156F, 0.0F, 0.0F); this.leg_left_thigh = new AdvancedModelBox(this, 62, 26); this.leg_left_thigh.setRotationPoint(2.5F, 0.6F, 5.2F); this.leg_left_thigh.addBox(-1.5F, -3.5F, -3.5F, 3, 8, 6, 0.0F); this.arm_left_1 = new AdvancedModelBox(this, 0, 0); this.arm_left_1.setRotationPoint(2.0F, 0.0F, -5.5F); this.arm_left_1.addBox(-1.5F, 0.0F, -2.0F, 3, 7, 4, 0.0F); this.setRotateAngle(arm_left_1, 0.136659280431156F, 0.0F, 0.0F); this.body_main = new AdvancedModelBox(this, 88, 42); this.body_main.setRotationPoint(0.0F, 13.0F, 0.0F); this.body_main.addBox(-3.0F, -5.0F, -7.0F, 6, 8, 14, 0.0F); this.head_ear_left = new AdvancedModelBox(this, 18, 32); this.head_ear_left.mirror = true; this.head_ear_left.setRotationPoint(2.5F, -2.0F, -1.4F); this.head_ear_left.addBox(-1.0F, -1.0F, 0.0F, 3, 2, 1, 0.0F); this.setRotateAngle(head_ear_left, 0.18203784098300857F, -0.18203784098300857F, 0.136659280431156F); this.leg_left_calf = new AdvancedModelBox(this, 86, 28); this.leg_left_calf.setRotationPoint(0.01F, 2.5F, 1.5F); this.leg_left_calf.addBox(-1.5F, 0.0F, -1.0F, 3, 8, 3, 0.0F); this.eye_left = new AdvancedModelBox(this, 0, 30); this.eye_left.setRotationPoint(2.51F, -1.0F, -3.0F); this.eye_left.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.eye_right = new AdvancedModelBox(this, 0, 30); this.eye_right.setRotationPoint(-2.51F, -1.0F, -3.0F); this.eye_right.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.arm_right_2 = new AdvancedModelBox(this, 0, 12); this.arm_right_2.mirror = true; this.arm_right_2.setRotationPoint(0.0F, 6.3F, 0.0F); this.arm_right_2.addBox(-1.5F, 0.0F, -1.5F, 3, 5, 3, 0.0F); this.setRotateAngle(arm_right_2, -0.136659280431156F, 0.0F, 0.0F); this.arm_left_2 = new AdvancedModelBox(this, 0, 12); this.arm_left_2.setRotationPoint(0.0F, 6.3F, 0.0F); this.arm_left_2.addBox(-1.5F, 0.0F, -1.5F, 3, 5, 3, 0.0F); this.setRotateAngle(arm_left_2, -0.136659280431156F, 0.0F, 0.0F); this.tail = new AdvancedModelBox(this, 65, 1); this.tail.setRotationPoint(0.0F, -5.0F, 7.0F); this.tail.addBox(-1.5F, 0.0F, 0.0F, 3, 10, 0, 0.0F); this.setRotateAngle(tail, 0.18203784098300857F, 0.0F, 0.0F); this.head_main = new AdvancedModelBox(this, 68, 51); this.head_main.setRotationPoint(0.0F, 1.7F, -5.0F); this.head_main.addBox(-2.5F, -4.5F, -5.0F, 5, 8, 5, 0.0F); this.setRotateAngle(head_main, -0.36425021489121656F, 0.0F, 0.0F); this.leg_right_thigh = new AdvancedModelBox(this, 62, 26); this.leg_right_thigh.mirror = true; this.leg_right_thigh.setRotationPoint(-2.5F, 0.6F, 5.2F); this.leg_right_thigh.addBox(-1.5F, -3.5F, -3.5F, 3, 8, 6, 0.0F); this.head_ear_right = new AdvancedModelBox(this, 18, 32); this.head_ear_right.setRotationPoint(-2.5F, -2.0F, -1.4F); this.head_ear_right.addBox(-2.0F, -1.0F, 0.0F, 3, 2, 1, 0.0F); this.setRotateAngle(head_ear_right, 0.18203784098300857F, 0.18203784098300857F, -0.136659280431156F); this.body_main.addChild(this.head_neck); this.leg_right_thigh.addChild(this.leg_right_calf); this.body_main.addChild(this.arm_right_1); this.body_main.addChild(this.leg_left_thigh); this.body_main.addChild(this.arm_left_1); this.head_main.addChild(this.head_ear_left); this.leg_left_thigh.addChild(this.leg_left_calf); this.head_main.addChild(this.eye_left); this.head_main.addChild(this.eye_right); this.arm_right_1.addChild(this.arm_right_2); this.arm_left_1.addChild(this.arm_left_2); this.body_main.addChild(this.tail); this.head_neck.addChild(this.head_main); this.body_main.addChild(this.leg_right_thigh); this.head_main.addChild(this.head_ear_right); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( body_main, leg_left_thigh, leg_right_thigh, tail, arm_right_1, arm_left_1, head_neck, arm_right_2, arm_left_2, head_main, head_ear_right, head_ear_left, eye_left, eye_right, leg_left_calf, leg_right_calf ); } public void setupAnim(EntityBison bison, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { resetToDefaultPose(); // Breathing Animation this.body_main.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); bob(body_main, 0.4F * 1.5f, 0.03F, false, ageInTicks / 20, 2); bob(arm_right_1, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(arm_left_1, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(leg_right_thigh, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(leg_left_thigh, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); // Blinking Animation if (!bison.shouldRenderEyes()) { this.eye_right.setRotationPoint(-1F, -2F, -2); this.eye_left.setRotationPoint(1F, -2.0F, -2.0F); } // Head Tracking Animation if (!bison.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 2, head_main); } // Movement Animation if (bison.canMove()) { this.arm_right_1.rotateAngleX = Mth.cos(limbSwing * 0.5F) * 1.4F * limbSwingAmount; this.arm_left_1.rotateAngleX = Mth.cos(limbSwing * 0.5F + (float) Math.PI) * 1.4F * limbSwingAmount; this.leg_left_thigh.rotateAngleX = Mth.cos(limbSwing * 0.5F + (float) Math.PI) * 1.4F * limbSwingAmount; this.leg_right_thigh.rotateAngleX = Mth.cos(limbSwing * 0.5F) * 1.4F * limbSwingAmount; } // Sitting Animation if (bison.sitProgress > 0) { this.progressPosition(body_main, bison.sitProgress, 0.0F, 17.5F, 0.0F, 40); this.progressRotation(head_neck, bison.sitProgress, (float) Math.toRadians(-33.91F), 0, 0, 40); this.progressRotation(head_main, bison.sitProgress, (float) Math.toRadians(-2.61F), 0, 0, 40); this.progressPosition(arm_right_1, bison.sitProgress, -4.5F, 0.2F, -2.0F, 40); this.progressRotation(arm_right_1, bison.sitProgress, (float) Math.toRadians(-65.22F), 0, 0, 40); this.progressRotation(arm_right_2, bison.sitProgress, (float) Math.toRadians(135.65F), 0.0F, (float) Math.toRadians(15.65F), 40); this.progressPosition(arm_left_1, bison.sitProgress, 4.5F, 0.2F, -2.0F, 40); this.progressRotation(arm_left_1, bison.sitProgress, (float) Math.toRadians(-65.22F), 0, 0, 40);this.progressRotation(arm_left_2, bison.sitProgress, (float) Math.toRadians(86.09F), 0.0F, (float) Math.toRadians(-5.22F), 40); this.progressRotation(arm_left_2, bison.sitProgress, (float) Math.toRadians(135.65F), 0.0F, (float) Math.toRadians(15.65F), 40); this.progressRotation(leg_right_thigh, bison.sitProgress, (float) Math.toRadians(-73.04F), (float) Math.toRadians(15.65F), 0, 40); this.progressRotation(leg_right_calf, bison.sitProgress, (float) Math.toRadians(-10.43F), 0.0F, (float) Math.toRadians(-10.43F), 40); this.progressRotation(leg_left_thigh, bison.sitProgress, (float) Math.toRadians(-73.04F), (float) Math.toRadians(-15.65F), 0, 40); this.progressRotation(leg_left_calf, bison.sitProgress, (float) Math.toRadians(-10.43F), 0.0F, (float) Math.toRadians(10.43F), 40); } // Sleeping Animation if (bison.sleepProgress > 0) { this.progressPosition(body_main, bison.sitProgress, 0.0F, 17.5F, 0.0F, 40); this.progressPosition(arm_right_1, bison.sitProgress, -4.5F, 0.2F, -2.0F, 40); this.progressRotation(arm_right_1, bison.sitProgress, (float) Math.toRadians(-65.22F), 0, 0, 40); this.progressRotation(arm_right_2, bison.sitProgress, (float) Math.toRadians(135.65F), 0.0F, (float) Math.toRadians(15.65F), 40); this.progressPosition(arm_left_1, bison.sitProgress, 4.5F, 0.2F, -2.0F, 40); this.progressRotation(arm_left_1, bison.sitProgress, (float) Math.toRadians(-65.22F), 0, 0, 40);this.progressRotation(arm_left_2, bison.sitProgress, (float) Math.toRadians(86.09F), 0.0F, (float) Math.toRadians(-5.22F), 40); this.progressRotation(arm_left_2, bison.sitProgress, (float) Math.toRadians(135.65F), 0.0F, (float) Math.toRadians(15.65F), 40); this.progressRotation(leg_right_thigh, bison.sitProgress, (float) Math.toRadians(-73.04F), (float) Math.toRadians(15.65F), 0, 40); this.progressRotation(leg_right_calf, bison.sitProgress, (float) Math.toRadians(-10.43F), 0.0F, (float) Math.toRadians(-10.43F), 40); this.progressRotation(leg_left_thigh, bison.sitProgress, (float) Math.toRadians(-73.04F), (float) Math.toRadians(-15.65F), 0, 40); this.progressRotation(leg_left_calf, bison.sitProgress, (float) Math.toRadians(-10.43F), 0.0F, (float) Math.toRadians(10.43F), 40); } } }
11,612
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelHippoCalf.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelHippoCalf.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityHippo; public class ModelHippoCalf extends AdvancedEntityModel<EntityHippo> { public AdvancedModelBox body_main; public AdvancedModelBox head_neck; public AdvancedModelBox leg_right; public AdvancedModelBox leg_left; public AdvancedModelBox arm_right; public AdvancedModelBox arm_left; public AdvancedModelBox head_face; public AdvancedModelBox head_jaw; public AdvancedModelBox face_ear_right; public AdvancedModelBox head_jaw_1; public AdvancedModelBox face_ear_left; public AdvancedModelBox eye_left; public AdvancedModelBox eye_right; public ModelHippoCalf() { this.texWidth = 128; this.texHeight = 64; this.leg_right = new AdvancedModelBox(this, 106, 40); this.leg_right.setRotationPoint(-2.51F, 2.5F, 6.51F); this.leg_right.addBox(-1.5F, 0.0F, -1.5F, 3, 5, 3, 0.0F); this.head_neck = new AdvancedModelBox(this, 80, 24); this.head_neck.setRotationPoint(0.0F, -0.5F, -6.5F); this.head_neck.addBox(-3.5F, -3.0F, -4.0F, 7, 6, 4, 0.0F); this.arm_right = new AdvancedModelBox(this, 106, 40); this.arm_right.setRotationPoint(-2.51F, 2.5F, -6.51F); this.arm_right.addBox(-1.5F, 0.0F, -1.5F, 3, 5, 3, 0.0F); this.head_face = new AdvancedModelBox(this, 80, 34); this.head_face.setRotationPoint(0.0F, 0.0F, -3.5F); this.head_face.addBox(-3.0F, -3.5F, -4.0F, 6, 6, 5, 0.0F); this.setRotateAngle(head_face, 0.136659280431156F, 0.0F, 0.0F); this.face_ear_right = new AdvancedModelBox(this, 102, 37); this.face_ear_right.setRotationPoint(-2.0F, -3.0F, -0.5F); this.face_ear_right.addBox(-2.0F, -2.0F, 0.0F, 2, 2, 1, 0.0F); this.setRotateAngle(face_ear_right, 0.136659280431156F, -0.091106186954104F, -0.36425021489121656F); this.head_jaw_1 = new AdvancedModelBox(this, 102, 31); this.head_jaw_1.setRotationPoint(0.0F, 0.0F, -4.0F); this.head_jaw_1.addBox(-3.0F, 0.0F, -3.0F, 6, 2, 3, 0.0F); this.eye_left = new AdvancedModelBox(this, 104, 38); this.eye_left.setRotationPoint(3.01F, -2.0F, -2.0F); this.eye_left.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.setRotateAngle(eye_left, -0.009075712110370514F, 0.0F, 0.0F); this.leg_left = new AdvancedModelBox(this, 106, 40); this.leg_left.mirror = true; this.leg_left.setRotationPoint(2.51F, 2.5F, 6.51F); this.leg_left.addBox(-1.5F, 0.0F, -1.5F, 3, 5, 3, 0.0F); this.head_jaw = new AdvancedModelBox(this, 102, 24); this.head_jaw.setRotationPoint(0.0F, -1.0F, -4.0F); this.head_jaw.addBox(-3.0F, -2.0F, -3.0F, 6, 3, 3, 0.0F); this.eye_right = new AdvancedModelBox(this, 102, 38); this.eye_right.setRotationPoint(-3.01F, -2.0F, -2.0F); this.eye_right.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.body_main = new AdvancedModelBox(this, 80, 0); this.body_main.setRotationPoint(0.0F, 16.5F, 0.0F); this.body_main.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 16, 0.0F); this.face_ear_left = new AdvancedModelBox(this, 102, 37); this.face_ear_left.mirror = true; this.face_ear_left.setRotationPoint(2.0F, -3.0F, -0.5F); this.face_ear_left.addBox(0.0F, -2.0F, 0.0F, 2, 2, 1, 0.0F); this.setRotateAngle(face_ear_left, 0.136659280431156F, 0.091106186954104F, 0.36425021489121656F); this.arm_left = new AdvancedModelBox(this, 106, 40); this.arm_left.mirror = true; this.arm_left.setRotationPoint(2.51F, 2.5F, -6.51F); this.arm_left.addBox(-1.5F, 0.0F, -1.5F, 3, 5, 3, 0.0F); this.body_main.addChild(this.leg_right); this.body_main.addChild(this.head_neck); this.body_main.addChild(this.arm_right); this.head_neck.addChild(this.head_face); this.head_face.addChild(this.face_ear_right); this.head_face.addChild(this.head_jaw_1); this.head_face.addChild(this.eye_left); this.body_main.addChild(this.leg_left); this.head_face.addChild(this.head_jaw); this.head_face.addChild(this.eye_right); this.head_face.addChild(this.face_ear_left); this.body_main.addChild(this.arm_left); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( body_main, head_neck, leg_right, leg_left, arm_right, arm_left, head_face, head_jaw, face_ear_right, head_jaw_1, face_ear_left, eye_left, eye_right ); } public void setupAnim(EntityHippo hippo, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { resetToDefaultPose(); this.body_main.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); bob(body_main, 0.4F * 1.5f, 0.03F, false, ageInTicks / 20, 2); bob(arm_right, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(arm_left, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(leg_right, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(leg_left, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); // Controls the head tracking if (!hippo.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 3, head_neck); this.faceTarget(netHeadYaw, headPitch, 3, head_face); } if (!hippo.shouldRenderEyes()) { this.eye_right.setRotationPoint(-1F, -2F, -2); this.eye_left.setRotationPoint(1F, -2.0F, -2.0F); } if (hippo.canMove()) { this.arm_right.rotateAngleX = Mth.cos(limbSwing * 0.5F) * 1.4F * limbSwingAmount; this.arm_left.rotateAngleX = Mth.cos(limbSwing * 0.5F + (float) Math.PI) * 1.4F * limbSwingAmount; this.leg_left.rotateAngleX = Mth.cos(limbSwing * 0.5F + (float) Math.PI) * 1.4F * limbSwingAmount; this.leg_right.rotateAngleX = Mth.cos(limbSwing * 0.5F) * 1.4F * limbSwingAmount; } } }
6,646
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelNewt.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelNewt.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.amphibian.EntityNewt; public class ModelNewt extends AdvancedEntityModel<EntityNewt> { private final AdvancedModelBox body_main; private final AdvancedModelBox head_main; private final AdvancedModelBox body_hip; private final AdvancedModelBox arm_right; private final AdvancedModelBox arm_left; private final AdvancedModelBox body_crest; private final AdvancedModelBox gill_l_1; private final AdvancedModelBox gill_l_2; private final AdvancedModelBox gill_r_1; private final AdvancedModelBox gill_r_2; private final AdvancedModelBox tail_1; private final AdvancedModelBox leg_right; private final AdvancedModelBox leg_left; private final AdvancedModelBox tail_2; private final AdvancedModelBox tail_1_crest; public ModelNewt() { this.texWidth = 32; this.texHeight = 16; this.leg_left = new AdvancedModelBox(this, 14, 5); this.leg_left.setRotationPoint(1.0F, 0.0F, 0.5F); this.leg_left.addBox(0.0F, -0.5F, -1.0F, 3, 1, 2, 0.0F); this.setRotateAngle(leg_left, 0.0F, -0.4553564018453205F, 0.5759586531581287F); this.body_crest = new AdvancedModelBox(this, 0, 0); this.body_crest.setRotationPoint(0.0F, -1.0F, 0.0F); this.body_crest.addBox(0.0F, -2.0F, -3.0F, 0, 2, 6, 0.0F); this.tail_1_crest = new AdvancedModelBox(this, 12, 4); this.tail_1_crest.setRotationPoint(0.0F, 0.0F, 2.5F); this.tail_1_crest.addBox(0.0F, -2.0F, -2.5F, 0, 2, 5, 0.0F); this.tail_1 = new AdvancedModelBox(this, 20, 10); this.tail_1.setRotationPoint(0.0F, -0.2F, 1.5F); this.tail_1.addBox(-1.0F, -0.5F, 0.0F, 2, 2, 4, 0.0F); this.setRotateAngle(tail_1, -0.24434609527920614F, 0.0F, 0.0F); this.tail_2 = new AdvancedModelBox(this, 22, 4); this.tail_2.setRotationPoint(0.0F, 0.0F, 3.6F); this.tail_2.addBox(-0.5F, -0.5F, 0.0F, 1, 2, 4, 0.0F); this.setRotateAngle(tail_2, 0.136659280431156F, 0.0F, 0.0F); this.arm_right = new AdvancedModelBox(this, 14, 5); this.arm_right.mirror = true; this.arm_right.setRotationPoint(-1.0F, 0.0F, -2.0F); this.arm_right.addBox(-3.0F, -0.5F, -1.0F, 3, 1, 2, 0.0F); this.setRotateAngle(arm_right, 0.0F, -0.5009094953223726F, -0.5759586531581287F); this.gill_l_2 = new AdvancedModelBox(this, 0, 0); this.gill_l_2.setRotationPoint(1.5F, -0.3F, -0.5F); this.gill_l_2.addBox(0.0F, -0.5F, 0.0F, 2, 1, 0, 0.0F); this.setRotateAngle(gill_l_2, 0.0F, -0.5009094953223726F, -0.18203784098300857F); this.leg_right = new AdvancedModelBox(this, 14, 5); this.leg_right.mirror = true; this.leg_right.setRotationPoint(-1.0F, 0.0F, 0.5F); this.leg_right.addBox(-3.0F, -0.5F, -1.0F, 3, 1, 2, 0.0F); this.setRotateAngle(leg_right, 0.0F, 0.4553564018453205F, -0.5759586531581287F); this.arm_left = new AdvancedModelBox(this, 14, 5); this.arm_left.setRotationPoint(1.0F, 0.0F, -2.0F); this.arm_left.addBox(0.0F, -0.5F, -1.0F, 3, 1, 2, 0.0F); this.setRotateAngle(arm_left, 0.0F, 0.5009094953223726F, 0.6373942428283291F); this.gill_r_2 = new AdvancedModelBox(this, 0, 0); this.gill_r_2.mirror = true; this.gill_r_2.setRotationPoint(-1.5F, -0.3F, -0.5F); this.gill_r_2.addBox(-2.0F, -0.5F, 0.0F, 2, 1, 0, 0.0F); this.setRotateAngle(gill_r_2, 0.0F, 0.5009094953223726F, 0.18203784098300857F); this.body_main = new AdvancedModelBox(this, 0, 0); this.body_main.setRotationPoint(0.0F, 22.3F, 0.0F); this.body_main.addBox(-1.5F, -1.0F, -4.0F, 3, 2, 4, 0.0F); this.body_hip = new AdvancedModelBox(this, 14, 0); this.body_hip.setRotationPoint(0.0F, 0.0F, 1.5F); this.body_hip.addBox(-1.51F, -1.0F, -1.5F, 3, 2, 3, 0.0F); this.gill_r_1 = new AdvancedModelBox(this, 0, 0); this.gill_r_1.mirror = true; this.gill_r_1.setRotationPoint(-1.5F, 0.3F, -0.5F); this.gill_r_1.addBox(-2.0F, -0.5F, 0.0F, 2, 1, 0, 0.0F); this.setRotateAngle(gill_r_1, 0.0F, 0.5009094953223726F, -0.22759093446006054F); this.head_main = new AdvancedModelBox(this, 0, 10); this.head_main.setRotationPoint(0.0F, -0.3F, -2.8F); this.head_main.addBox(-1.5F, -1.01F, -4.0F, 3, 2, 4, 0.0F); this.setRotateAngle(head_main, 0.136659280431156F, 0.0F, 0.0F); this.head_main.scaleX = 1.05F; this.gill_l_1 = new AdvancedModelBox(this, 0, 0); this.gill_l_1.setRotationPoint(1.5F, 0.3F, -0.5F); this.gill_l_1.addBox(0.0F, -0.5F, 0.0F, 2, 1, 0, 0.0F); this.setRotateAngle(gill_l_1, 0.0F, -0.5009094953223726F, 0.22759093446006054F); this.body_hip.addChild(this.leg_left); this.body_main.addChild(this.body_crest); this.tail_1.addChild(this.tail_1_crest); this.body_hip.addChild(this.tail_1); this.tail_1.addChild(this.tail_2); this.body_main.addChild(this.arm_right); this.head_main.addChild(this.gill_l_2); this.body_hip.addChild(this.leg_right); this.body_main.addChild(this.arm_left); this.head_main.addChild(this.gill_r_2); this.body_main.addChild(this.body_hip); this.head_main.addChild(this.gill_r_1); this.body_main.addChild(this.head_main); this.head_main.addChild(this.gill_l_1); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of(body_main, head_main, body_hip, arm_right, arm_left, leg_left, leg_right, body_crest, tail_1_crest, tail_2, tail_1, gill_l_1, gill_l_2, gill_r_1, gill_r_2 ); } public void setupAnim(EntityNewt newt, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { resetToDefaultPose(); float globalSpeed = 0.8f; float globalDegree = 1.0f; limbSwingAmount = Math.min(0.6F, limbSwingAmount); // Breathing Animation this.body_hip.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.body_main.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.head_main.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); // Head Tracking Animation if (!newt.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 2, head_main); } // Pitch/Yaw handler if (newt.isInWater() && !newt.isOnGround()) { this.setRotateAngle(body_main, newt.getXRot() * ((float) Math.PI / 180F), 0, 0); } this.head_main.rotateAngleY = Mth.rotLerp((float) 0.05, this.head_main.rotateAngleY, newt.offset); this.body_hip.rotateAngleY = Mth.rotLerp((float) 0.05, this.body_hip.rotateAngleY, -1F * newt.offset); this.tail_2.rotateAngleY = Mth.rotLerp((float) 0.05, this.tail_2.rotateAngleY, -2F * newt.offset); // Movement Animation AdvancedModelBox[] bodyParts = new AdvancedModelBox[]{head_main, body_main, body_hip, tail_1, tail_2}; chainSwing(bodyParts, globalSpeed * 1.4F, globalDegree * 1.2F, -4, limbSwing, limbSwingAmount * 0.3F); float onGround = Math.min(0.8F, limbSwingAmount * (newt.isOnGround() ? 2 : 1)); if (newt.isInWater()) { flap(arm_left, globalSpeed, globalDegree, false, 0.8F, 1f, limbSwing, limbSwingAmount); flap(leg_left, globalSpeed, globalDegree * 0.8f, false, 1.6F, 1f, limbSwing, limbSwingAmount); flap(arm_right, globalSpeed, globalDegree, false, 2.4F, 1f, limbSwing, limbSwingAmount); flap(leg_right, globalSpeed, globalDegree * 0.8f, false, 3.2F, 1f, limbSwing, limbSwingAmount); flap(body_main, globalSpeed / 2, globalDegree * 1.2f, false, 0, 0.1f, limbSwing / 2, limbSwingAmount); swing(body_main, globalSpeed / 2, globalDegree * 1.2f, false, 0.8F, 0.1f, limbSwing / 3, limbSwingAmount); chainWave(new AdvancedModelBox[]{head_main, body_main, body_hip}, globalSpeed * 0.8F, globalDegree, -4, limbSwing, limbSwingAmount * 0.2F); } else { swing(arm_left, globalSpeed, globalDegree * 1.2f, false, 0.8F, 1f, limbSwing, onGround); swing(leg_left, globalSpeed, globalDegree * 1.1f, false, 1.6F, 1f, limbSwing, onGround); swing(arm_right, globalSpeed, globalDegree * 1.2f, false, 2.4F, 1f, limbSwing, onGround); swing(leg_right, globalSpeed, globalDegree * 1.1f, false, 3.2F, 1f, limbSwing, onGround); } // Sleeping Animation if (newt.swimProgress > 0) { this.progressRotation(arm_right, newt.swimProgress, (float) Math.toRadians(41.74F), (float) Math.toRadians(70.43F), (float) Math.toRadians(-36.52F), 20); this.progressRotation(arm_left, newt.swimProgress, (float) Math.toRadians(41.74F), (float) Math.toRadians(-70.43F), (float) Math.toRadians(36.52F), 20); this.progressRotation(leg_right, newt.swimProgress, (float) Math.toRadians(49.57F), (float) Math.toRadians(73.04F), (float) Math.toRadians(-33.91F), 20); this.progressRotation(leg_left, newt.swimProgress, (float) Math.toRadians(49.57F), (float) Math.toRadians(-73.04F), (float) Math.toRadians(33.91F), 20); } } }
9,961
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelTarantula.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelTarantula.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import untamedwilds.entity.arthropod.EntityTarantula; public class ModelTarantula extends AdvancedEntityModel<EntityTarantula> { public AdvancedModelBox body_main; public AdvancedModelBox abdomen; public AdvancedModelBox legR4; public AdvancedModelBox legR3; public AdvancedModelBox legR2; public AdvancedModelBox legR1; public AdvancedModelBox legL4; public AdvancedModelBox legL3; public AdvancedModelBox legL2; public AdvancedModelBox legL1; public AdvancedModelBox legR42; public AdvancedModelBox legR32; public AdvancedModelBox legR22; public AdvancedModelBox legR12; public AdvancedModelBox legL42; public AdvancedModelBox legL32; public AdvancedModelBox legL22; public AdvancedModelBox legL12; public ModelTarantula() { this.texWidth = 64; this.texHeight = 32; this.legL32 = new AdvancedModelBox(this, 24, 16); this.legL32.setRotationPoint(-4.0F, -0.9F, 0.01F); this.legL32.addBox(-1.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F); this.legL12 = new AdvancedModelBox(this, 0, 16); this.legL12.setRotationPoint(-3.5F, -0.9F, -0.01F); this.legL12.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(legL12, 0.41887902047863906F, 0.0F, 0.3490658503988659F); this.legL1 = new AdvancedModelBox(this, 0, 12); this.legL1.setRotationPoint(2.0F, 1.0F, -2.6F); this.legL1.addBox(-4.0F, -1.0F, -1.0F, 4, 2, 2, 0.0F); this.setRotateAngle(legL1, 0.13962634015954636F, -2.356194490192345F, -0.3141592653589793F); this.legR2 = new AdvancedModelBox(this, 12, 12); this.legR2.setRotationPoint(-2.6F, 1.0F, -1.0F); this.legR2.addBox(-4.0F, -1.0F, -1.0F, 4, 2, 2, 0.0F); this.setRotateAngle(legR2, -0.2617993877991494F, -0.3141592653589793F, 0.5759586531581287F); this.legL3 = new AdvancedModelBox(this, 24, 12); this.legL3.setRotationPoint(2.6F, 1.0F, 1.0F); this.legL3.addBox(-4.0F, -1.0F, -1.0F, 4, 2, 2, 0.0F); this.setRotateAngle(legL3, -0.3141592653589793F, 2.6878070480712672F, -0.5759586531581287F); this.legR1 = new AdvancedModelBox(this, 0, 12); this.legR1.setRotationPoint(-2.0F, 1.0F, -2.6F); this.legR1.addBox(-4.0F, -1.0F, -1.0F, 4, 2, 2, 0.0F); this.setRotateAngle(legR1, -0.045553093477052F, -0.7853981633974483F, 0.3141592653589793F); this.legR32 = new AdvancedModelBox(this, 24, 16); this.legR32.setRotationPoint(-4.0F, -0.9F, 0.01F); this.legR32.addBox(-1.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F); this.legL2 = new AdvancedModelBox(this, 12, 12); this.legL2.setRotationPoint(2.6F, 1.0F, -1.0F); this.legL2.addBox(-4.0F, -1.0F, -1.0F, 4, 2, 2, 0.0F); this.setRotateAngle(legL2, 0.2617993877991494F, -2.827433388230814F, -0.5759586531581287F); this.legR22 = new AdvancedModelBox(this, 12, 16); this.legR22.setRotationPoint(-4.0F, -0.9F, -0.01F); this.legR22.addBox(-1.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F); this.legL4 = new AdvancedModelBox(this, 36, 12); this.legL4.setRotationPoint(3.0F, 1.0F, 2.0F); this.legL4.addBox(-4.0F, -1.0F, -2.0F, 4, 2, 2, 0.0F); this.setRotateAngle(legL4, -0.3490658503988659F, 2.2689280275926285F, -0.3490658503988659F); this.legR3 = new AdvancedModelBox(this, 24, 12); this.legR3.setRotationPoint(-2.6F, 1.0F, 1.0F); this.legR3.addBox(-4.0F, -1.0F, -1.0F, 4, 2, 2, 0.0F); this.setRotateAngle(legR3, 0.3141592653589793F, 0.41887902047863906F, 0.5759586531581287F); this.legR12 = new AdvancedModelBox(this, 0, 16); this.legR12.setRotationPoint(-3.5F, -0.9F, -0.01F); this.legR12.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, 0.0F); this.setRotateAngle(legR12, -0.41887902047863906F, 0.0F, 0.3490658503988659F); this.legR42 = new AdvancedModelBox(this, 36, 16); this.legR42.setRotationPoint(-3.5F, 0.0F, 1.01F); this.legR42.addBox(-1.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F); this.setRotateAngle(legR42, 0.0F, 0.0F, 0.7853981633974483F); this.legL42 = new AdvancedModelBox(this, 36, 16); this.legL42.setRotationPoint(-3.5F, 0.0F, -0.99F); this.legL42.addBox(-1.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F); this.setRotateAngle(legL42, 0.0F, 0.0F, 0.7853981633974483F); this.legL22 = new AdvancedModelBox(this, 12, 16); this.legL22.setRotationPoint(-4.0F, -0.9F, -0.01F); this.legL22.addBox(-1.0F, 0.0F, -1.0F, 2, 7, 2, 0.0F); this.body_main = new AdvancedModelBox(this, 0, 0); this.body_main.setRotationPoint(0.0F, 20.0F, 0.0F); this.body_main.addBox(-3.0F, 0.0F, -3.0F, 6, 3, 6, 0.0F); this.legR4 = new AdvancedModelBox(this, 36, 12); this.legR4.setRotationPoint(-3.0F, 1.0F, 2.0F); this.legR4.addBox(-4.0F, -1.0F, 0.0F, 4, 2, 2, 0.0F); this.setRotateAngle(legR4, 0.3490658503988659F, 0.8726646259971648F, 0.3490658503988659F); this.abdomen = new AdvancedModelBox(this, 24, 0); this.abdomen.setRotationPoint(0.0F, 1.0F, 2.5F); this.abdomen.addBox(-3.5F, -2.0F, 0.0F, 7, 4, 7, 0.0F); this.setRotateAngle(abdomen, -0.17453292519943295F, 0.0F, 0.0F); this.legL3.addChild(this.legL32); this.legL1.addChild(this.legL12); this.body_main.addChild(this.legL1); this.body_main.addChild(this.legR2); this.body_main.addChild(this.legL3); this.body_main.addChild(this.legR1); this.legR3.addChild(this.legR32); this.body_main.addChild(this.legL2); this.legR2.addChild(this.legR22); this.body_main.addChild(this.legL4); this.body_main.addChild(this.legR3); this.legR1.addChild(this.legR12); this.legR4.addChild(this.legR42); this.legL4.addChild(this.legL42); this.legL2.addChild(this.legL22); this.body_main.addChild(this.legR4); this.body_main.addChild(this.abdomen); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of(body_main, abdomen, legR4, legR3, legR2, legR1, legL4, legL3, legL2, legL1, legR42, legR32, legR22, legR12, legL42, legL32, legL22, legL12 ); } public void setupAnim(EntityTarantula tarantula, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { resetToDefaultPose(); limbSwing = ageInTicks; limbSwingAmount = Math.min(0.4F, limbSwingAmount); float globalSpeed = 1.2f; float globalDegree = 1.4f; this.abdomen.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F)); bob(body_main, 0.4F * 1.5f, 0.03F, false, ageInTicks / 20, 2); bob(legR1, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(legL1, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(legR2, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(legL2, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(legR3, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(legL3, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(legR4, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(legL4, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); // Attacking animation if (tarantula.aggroProgress != 0) { this.progressRotation(legR1, tarantula.aggroProgress, (float)Math.toRadians(-41.74D), 0, (float)Math.toRadians(75.65F), 40); this.progressRotation(legL1, tarantula.aggroProgress, (float)Math.toRadians(41.74D), (float)Math.toRadians(-180D), (float)Math.toRadians(-75.65F), 40); } else { animateArthropodLeg(legL1, legL12, globalSpeed, globalDegree, 3, limbSwing, limbSwingAmount); animateArthropodLeg(legR1, legR12, globalSpeed, globalDegree, 0, limbSwing, limbSwingAmount); } if (!tarantula.isClimbing()) { animateArthropodLeg(legL2, legL22, globalSpeed, globalDegree, 4, limbSwing, limbSwingAmount); animateArthropodLeg(legL3, legL32, globalSpeed, globalDegree, 0, limbSwing, limbSwingAmount); animateArthropodLeg(legL4, legL42, globalSpeed, globalDegree, 1, limbSwing, limbSwingAmount); animateArthropodLeg(legR2, legR22, globalSpeed, globalDegree, 2, limbSwing, limbSwingAmount); animateArthropodLeg(legR3, legR32, globalSpeed, globalDegree, 3, limbSwing, limbSwingAmount); animateArthropodLeg(legR4, legR42, globalSpeed, globalDegree, 5, limbSwing, limbSwingAmount); } // Climbing animation this.progressRotation(body_main, tarantula.climbProgress, 90 * ((float)Math.PI / 180F) * (tarantula.invertClimbing ? 1 : -1), body_main.rotateAngleY, body_main.rotateAngleZ , 20); if (tarantula.isClimbing() && Math.abs(tarantula.getDeltaMovement().y()) > 0.05F) { float swing = tarantula.getDeltaMovement().y() != 0 ? 0.3F : limbSwingAmount; animateArthropodLeg(legL2, legL22, globalSpeed, globalDegree, 4, ageInTicks / 3, swing); animateArthropodLeg(legL3, legL32, globalSpeed, globalDegree, 0, ageInTicks / 3, swing); animateArthropodLeg(legL4, legL42, globalSpeed, globalDegree, 1, ageInTicks / 3, swing); animateArthropodLeg(legR2, legR22, globalSpeed, globalDegree, 2, ageInTicks / 3, swing); animateArthropodLeg(legR3, legR32, globalSpeed, globalDegree, 3, ageInTicks / 3, swing); animateArthropodLeg(legR4, legR42, globalSpeed, globalDegree, 5, ageInTicks / 3, swing); } } private void animateArthropodLeg(AdvancedModelBox limb_1, AdvancedModelBox limb_2, float speed, float degree, int offset, float limbSwing, float limbSwingAmount) { swing(limb_1, speed, degree * 1.2f, false, offset, 0.1f, limbSwing, limbSwingAmount); flap(limb_1, speed, degree * 0.8f, true, offset + 1.5F, 0.2f, limbSwing, limbSwingAmount); flap(limb_2, speed, degree * 0.8f, true, offset + 1.5F, 0f, limbSwing, limbSwingAmount); } }
10,663
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelManatee.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelManatee.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.UntamedWilds; import untamedwilds.entity.fish.EntitySunfish; import untamedwilds.entity.mammal.EntityHippo; import untamedwilds.entity.mammal.EntityManatee; public class ModelManatee extends AdvancedEntityModel<EntityManatee> { public AdvancedModelBox body_main; public AdvancedModelBox body_torso; public AdvancedModelBox body_tail_1; public AdvancedModelBox head_face; public AdvancedModelBox arm_right; public AdvancedModelBox arm_left; public AdvancedModelBox head_snout_1; public AdvancedModelBox head_jaw; public AdvancedModelBox head_snout_2; public AdvancedModelBox body_tail_2; public AdvancedModelBox body_tail_3; public AdvancedModelBox body_tail_4; public AdvancedModelBox body_tail_5; public AdvancedModelBox body_tail_6; private static AdvancedModelBox[] bodyParts_passive; private static AdvancedModelBox[] bodyParts_head; public ModelManatee() { this.texWidth = 128; this.texHeight = 64; this.head_jaw = new AdvancedModelBox(this, 0, 56); this.head_jaw.setRotationPoint(0.0F, 2.0F, -4.0F); this.head_jaw.addBox(-2.0F, 0.0F, -4.0F, 4, 1, 4, 0.0F); this.setRotateAngle(head_jaw, -0.136659280431156F, 0.0F, 0.0F); this.body_tail_4 = new AdvancedModelBox(this, 84, 14); this.body_tail_4.setRotationPoint(0.0F, 0.0F, 3.0F); this.body_tail_4.addBox(-6.0F, -1.0F, 0.0F, 12, 2, 10, 0.0F); this.head_snout_1 = new AdvancedModelBox(this, 28, 42); this.head_snout_1.setRotationPoint(0.0F, -0.99F, -6.0F); this.head_snout_1.addBox(-3.5F, -3.0F, -4.0F, 7, 6, 4, 0.0F); this.body_main = new AdvancedModelBox(this, 0, 0); this.body_main.setRotationPoint(0.0F, 13.0F, 0.0F); this.body_main.addBox(-7.0F, -6.0F, -6.0F, 14, 12, 12, 0.0F); this.arm_right = new AdvancedModelBox(this, 52, 34); this.arm_right.mirror = true; this.arm_right.setRotationPoint(-6.0F, 4.5F, -5.0F); this.arm_right.addBox(-6.0F, -0.5F, -2.0F, 6, 2, 5, 0.0F); this.setRotateAngle(arm_right, 0.045553093477052F, 0.0F, -2.367539130330308F); this.body_tail_1 = new AdvancedModelBox(this, 52, 0); this.body_tail_1.setRotationPoint(0.0F, 0.0F, 5.0F); this.body_tail_1.addBox(-6.0F, -5.0F, 0.0F, 12, 10, 8, 0.0F); this.setRotateAngle(body_tail_1, -0.091106186954104F, 0.0F, 0.0F); this.body_torso = new AdvancedModelBox(this, 0, 24); this.body_torso.setRotationPoint(0.0F, 0.0F, -6.0F); this.body_torso.addBox(-6.0F, -5.0F, -7.0F, 12, 10, 8, 0.0F); this.setRotateAngle(body_torso, 0.045553093477052F, 0.0F, 0.0F); this.arm_left = new AdvancedModelBox(this, 52, 34); this.arm_left.setRotationPoint(6.0F, 4.5F, -5.0F); this.arm_left.addBox(0.0F, -0.5F, -2.0F, 6, 2, 5, 0.0F); this.setRotateAngle(arm_left, 0.045553093477052F, 0.0F, 2.367539130330308F); this.body_tail_3 = new AdvancedModelBox(this, 92, 0); this.body_tail_3.setRotationPoint(0.0F, -0.5F, 7.0F); this.body_tail_3.addBox(-3.0F, -2.5F, 0.0F, 6, 5, 8, 0.0F); this.setRotateAngle(body_tail_3, 0.091106186954104F, 0.0F, 0.0F); this.head_face = new AdvancedModelBox(this, 0, 42); this.head_face.setRotationPoint(0.0F, 0.0F, -6.0F); this.head_face.addBox(-4.0F, -4.0F, -6.0F, 8, 7, 6, 0.0F); this.setRotateAngle(head_face, 0.045553093477052F, 0.0F, 0.0F); this.body_tail_5 = new AdvancedModelBox(this, 90, 26); this.body_tail_5.mirror = true; this.body_tail_5.setRotationPoint(0.0F, 0.0F, 3.0F); this.body_tail_5.addBox(-14.0F, -1.0F, -1.0F, 12, 2, 6, 0.0F); this.setRotateAngle(body_tail_5, 0.0F, 0.5918411493512771F, 0.0F); this.body_tail_6 = new AdvancedModelBox(this, 90, 26); this.body_tail_6.setRotationPoint(0.0F, 0.0F, 3.0F); this.body_tail_6.addBox(2.0F, -1.0F, -1.0F, 12, 2, 6, 0.0F); this.setRotateAngle(body_tail_6, 0.0F, -0.5918411493512771F, 0.0F); this.head_snout_2 = new AdvancedModelBox(this, 30, 54); this.head_snout_2.setRotationPoint(0.0F, 0.82F, -0.8F); this.head_snout_2.addBox(-4.0F, -3.0F, -4.0F, 8, 6, 4, 0.0F); this.setRotateAngle(head_snout_2, -0.22759093446006054F, 0.0F, 0.0F); this.body_tail_2 = new AdvancedModelBox(this, 52, 18); this.body_tail_2.setRotationPoint(0.0F, 0.0F, 7.0F); this.body_tail_2.addBox(-5.0F, -4.0F, 0.0F, 10, 7, 8, 0.0F); this.setRotateAngle(body_tail_2, -0.091106186954104F, 0.0F, 0.0F); this.head_face.addChild(this.head_jaw); this.body_tail_3.addChild(this.body_tail_4); this.head_face.addChild(this.head_snout_1); this.body_torso.addChild(this.arm_right); this.body_main.addChild(this.body_tail_1); this.body_main.addChild(this.body_torso); this.body_torso.addChild(this.arm_left); this.body_tail_2.addChild(this.body_tail_3); this.body_torso.addChild(this.head_face); this.body_tail_3.addChild(this.body_tail_5); this.body_tail_3.addChild(this.body_tail_6); this.head_snout_1.addChild(this.head_snout_2); this.body_tail_1.addChild(this.body_tail_2); bodyParts_passive = new AdvancedModelBox[]{body_main, body_tail_1, body_tail_2, body_tail_3}; bodyParts_head = new AdvancedModelBox[]{head_face, head_jaw, head_snout_1, head_snout_2}; updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( body_main, body_torso, body_tail_1, head_face, arm_right, arm_left, head_snout_1, head_jaw, head_snout_2, body_tail_2, body_tail_3, body_tail_4, body_tail_5, body_tail_6 ); } public void setupAnim(EntityManatee manatee, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { float f = ageInTicks - (float)manatee.tickCount / 20; resetToDefaultPose(); float globalSpeed = 0.6f; float globalDegree = 0.6f; if (manatee.isEating()) { this.head_snout_2.setScale((float) (1.0F + Math.sin(ageInTicks / 6) * 0.08F + Math.sin(ageInTicks / 2) * 0.1F), (float) (1.0F + Math.sin(ageInTicks / 8) * 0.04F), 1.0F); } // Pitch/Yaw handler if (manatee.isInWater()) { this.setRotateAngle(body_main, manatee.getXRot() * ((float) Math.PI / 180F), 0, 0); } // Movement Animation float partialTicks = ageInTicks - manatee.tickCount; float renderYaw = (float)manatee.getMovementOffsets(0, partialTicks)[0]; this.body_tail_1.rotateAngleY += smartClamp((float)manatee.getMovementOffsets(15, partialTicks)[0] - renderYaw, -40, 40) * ((float) Math.PI / 180F) * 0.3F; this.body_tail_2.rotateAngleY += smartClamp((float)manatee.getMovementOffsets(17, partialTicks)[0] - renderYaw, -40, 40) * ((float) Math.PI / 180F) * 0.3F; this.body_main.rotateAngleZ += smartClamp((float)manatee.getMovementOffsets(7, partialTicks)[0] - renderYaw, -20, 20) * ((float) Math.PI / 180F) * 0.3F; walk(body_main, globalSpeed * 0.2F, globalDegree * 0.2f, true, 0, 0, f, Math.max(0.4F, limbSwingAmount)); walk(body_tail_1, globalSpeed * 0.2F, globalDegree * 0.6f, true, 1.2f, 0, f, Math.max(0.4F, limbSwingAmount)); walk(body_tail_2, globalSpeed * 0.2F, globalDegree * 0.6f, true, 2.4f, 0, f, Math.max(0.4F, limbSwingAmount)); walk(body_tail_3, globalSpeed * 0.2F, globalDegree * 0.4f, true, 3.6f, 0, f, Math.max(0.4F, limbSwingAmount)); } // This wrapper handles cases where the returned MovementOffset is a large negative angle, which throws off the clamp function public float smartClamp(float angle, int min, int max) { float val = Math.abs(angle); if (val > 180) { angle = 360 - val; } return Mth.clamp(angle, min, max); } }
8,677
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelCamelCalf.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelCamelCalf.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityCamel; public class ModelCamelCalf extends AdvancedEntityModel<EntityCamel> { public AdvancedModelBox body_main; public AdvancedModelBox arm_left; public AdvancedModelBox arm_right; public AdvancedModelBox arm_left_2; public AdvancedModelBox arm_right_2; public AdvancedModelBox neck; public AdvancedModelBox leg_left_calf; public AdvancedModelBox leg_right_calf; public AdvancedModelBox head_main; public AdvancedModelBox head_nose; public AdvancedModelBox head_nose_1; public AdvancedModelBox ear_left; public AdvancedModelBox ear_right; public AdvancedModelBox leg_left_calf_1; public AdvancedModelBox leg_right_calf_1; public AdvancedModelBox eye_left; public AdvancedModelBox eye_right; public ModelCamelCalf() { this.texWidth = 128; this.texHeight = 64; this.ear_right = new AdvancedModelBox(this, 16, 0); this.ear_right.setRotationPoint(-3.0F, -3.0F, -1.0F); this.ear_right.addBox(-3.0F, -2.0F, 0.0F, 3, 3, 1, 0.0F); this.setRotateAngle(ear_right, 0.7285004297824331F, 0.5009094953223726F, 0.7740535232594852F); this.head_nose = new AdvancedModelBox(this, 94, 0); this.head_nose.setRotationPoint(0.0F, -4.5F, -6.0F); this.head_nose.addBox(-3.0F, 0.0F, -6.0F, 6, 3, 6, 0.0F); this.setRotateAngle(head_nose, 0.18203784098300857F, 0.0F, 0.0F); this.leg_right_calf_1 = new AdvancedModelBox(this, 84, 26); this.leg_right_calf_1.mirror = true; this.leg_right_calf_1.setRotationPoint(0.0F, 9.0F, 0.0F); this.leg_right_calf_1.addBox(-1.5F, 0.0F, -1.5F, 3, 11, 3, 0.0F); this.setRotateAngle(leg_right_calf_1, -0.40980330836826856F, 0.0F, 0.0F); this.body_main = new AdvancedModelBox(this, 8, 6); this.body_main.setRotationPoint(0.0F, 7.3F, 0.0F); this.body_main.addBox(-3.0F, -5.0F, -9.0F, 6, 10, 18, 0.0F); this.setRotateAngle(body_main, -0.045553093477052F, 0.0F, 0.0F); this.leg_left_calf_1 = new AdvancedModelBox(this, 84, 26); this.leg_left_calf_1.setRotationPoint(0.0F, 9.0F, 0.0F); this.leg_left_calf_1.addBox(-1.5F, 0.0F, -1.5F, 3, 11, 3, 0.0F); this.setRotateAngle(leg_left_calf_1, -0.40980330836826856F, 0.0F, 0.0F); this.leg_left_calf = new AdvancedModelBox(this, 68, 20); this.leg_left_calf.setRotationPoint(-2.5F, -2.5F, 6.5F); this.leg_left_calf.addBox(-2.0F, 0.0F, -2.0F, 4, 10, 4, 0.0F); this.setRotateAngle(leg_left_calf, 0.4553564018453205F, 0.0F, 0.0F); this.head_nose_1 = new AdvancedModelBox(this, 62, 0); this.head_nose_1.setRotationPoint(0.0F, -1.8F, -6.0F); this.head_nose_1.addBox(-2.5F, 0.0F, -5.0F, 5, 2, 5, 0.0F); this.neck = new AdvancedModelBox(this, 58, 34); this.neck.setRotationPoint(0.0F, 0.0F, -9.2F); this.neck.addBox(-2.5F, -2.5F, -8.5F, 5, 5, 10, 0.0F); this.setRotateAngle(neck, -0.9560913642424937F, 0.0F, 0.0F); this.arm_right = new AdvancedModelBox(this, 84, 20); this.arm_right.mirror = true; this.arm_right.setRotationPoint(-2.5F, 0.05F, -7.99F); this.arm_right.addBox(-1.5F, 0.0F, -1.5F, 3, 7, 3, 0.0F); this.setRotateAngle(arm_right, 0.045553093477052F, 0.0F, 0.0F); this.arm_left = new AdvancedModelBox(this, 84, 20); this.arm_left.setRotationPoint(2.5F, 0.05F, -7.99F); this.arm_left.addBox(-1.5F, 0.0F, -1.5F, 3, 7, 3, 0.0F); this.setRotateAngle(arm_left, 0.045553093477052F, 0.0F, 0.0F); this.arm_right_2 = new AdvancedModelBox(this, 84, 27); this.arm_right_2.mirror = true; this.arm_right_2.setRotationPoint(0, 7, 0F); this.arm_right_2.addBox(-1.5F, 0.0F, -1.5F, 3, 10, 3, 0.0F); this.setRotateAngle(arm_right_2, 0.045553093477052F, 0.0F, 0.0F); this.arm_left_2 = new AdvancedModelBox(this, 84, 27); this.arm_left_2.setRotationPoint(0, 7, 0); this.arm_left_2.addBox(-1.5F, 0.0F, -1.5F, 3, 10, 3, 0.0F); this.setRotateAngle(arm_left_2, 0.045553093477052F, 0.0F, 0.0F); this.leg_right_calf = new AdvancedModelBox(this, 68, 20); this.leg_right_calf.mirror = true; this.leg_right_calf.setRotationPoint(2.5F, -2.5F, 6.5F); this.leg_right_calf.addBox(-2.0F, 0.0F, -2.0F, 4, 10, 4, 0.0F); this.setRotateAngle(leg_right_calf, 0.4553564018453205F, 0.0F, 0.0F); this.head_main = new AdvancedModelBox(this, 0, 36); this.head_main.setRotationPoint(0.0F, -2.4F, -6.3F); this.head_main.addBox(-3.0F, -5F, -6.0F, 6, 5, 6, 0.0F); this.setRotateAngle(head_main, 1.2747884856566583F, 0.0F, 0.0F); this.ear_left = new AdvancedModelBox(this, 16, 0); this.ear_left.setRotationPoint(3.0F, -3.0F, -1.0F); this.ear_left.addBox(0.0F, -2.0F, 0.0F, 3, 3, 1, 0.0F); this.setRotateAngle(ear_left, 0.7285004297824331F, -0.5009094953223726F, -0.7740535232594852F); this.eye_right = new AdvancedModelBox(this, 0, 0); this.eye_right.mirror = true; this.eye_right.setRotationPoint(-3.01F, -3.0F, -4.0F); this.eye_right.addBox(0.0F, -1F, -1.0F, 0, 1, 2, 0.0F); this.eye_left = new AdvancedModelBox(this, 0, 0); this.eye_left.setRotationPoint(3.01F, -3.0F, -4.0F); this.eye_left.addBox(0.0F, -1F, -1.0F, 0, 1, 2, 0.0F); this.head_main.addChild(this.ear_right); this.head_main.addChild(this.head_nose); this.arm_left.addChild(this.arm_left_2); this.arm_right.addChild(this.arm_right_2); this.leg_right_calf.addChild(this.leg_right_calf_1); this.leg_left_calf.addChild(this.leg_left_calf_1); this.body_main.addChild(this.leg_left_calf); this.head_main.addChild(this.head_nose_1); this.body_main.addChild(this.neck); this.body_main.addChild(this.arm_right); this.body_main.addChild(this.arm_left); this.body_main.addChild(this.leg_right_calf); this.neck.addChild(this.head_main); this.head_main.addChild(this.ear_left); this.head_main.addChild(this.eye_left); this.head_main.addChild(this.eye_right); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( body_main, arm_left, arm_right, arm_left_2, arm_right_2, neck, leg_left_calf, leg_left_calf_1, leg_right_calf, leg_right_calf_1, head_main, head_nose, head_nose_1, ear_left, ear_right, eye_left, eye_right ); } public void setupAnim(EntityCamel camel, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { resetToDefaultPose(); // Breathing Animation this.body_main.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); bob(body_main, 0.4F * 1.5f, 0.03F, false, ageInTicks / 20, 2); bob(arm_right, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(arm_left, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(leg_right_calf, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); bob(leg_left_calf, 0.4F * 1.5f, 0.03F, false, -ageInTicks / 20, 2); // Blinking Animation if (!camel.shouldRenderEyes()) { this.eye_right.setRotationPoint(-1F, -2F, -2); this.eye_left.setRotationPoint(1F, -2.0F, -2.0F); } // Head Tracking Animation if (!camel.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 2, neck); this.faceTarget(netHeadYaw, headPitch, 2, head_main); } // Movement Animation if (camel.canMove()) { flap(body_main, 0.5F, 0.2F,false, 0, 0, limbSwing, limbSwingAmount); flap(neck, 0.5F, 0.2F,true, 0.2F, 0, limbSwing, limbSwingAmount); bob(arm_right, 0.5F, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_right, 0.5f, 1, true, 0F, 0f, limbSwing, limbSwingAmount); walk(arm_right_2, 0.5f, 0.6f, true, 0.2F, 0.2f, limbSwing, limbSwingAmount); bob(arm_left, 0.5F, 0.8F, false, limbSwing, limbSwingAmount); walk(arm_left, 0.5f, 1, true, 2.4F, 0f, limbSwing, limbSwingAmount); walk(arm_left_2, 0.5f, 0.6f, true, 2.6F, 0.2f, limbSwing, limbSwingAmount); bob(leg_right_calf, 0.5F, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_right_calf, 0.5f, 1, true, 0.2F, 0f, limbSwing, limbSwingAmount); walk(leg_right_calf_1, 0.5f, 0.6f, true, 0.4F, 0.2f, limbSwing, limbSwingAmount); bob(leg_left_calf, 0.5F, 0.8F, false, limbSwing, limbSwingAmount); walk(leg_left_calf, 0.5f, 1, true, 2.6F, 0f, limbSwing, limbSwingAmount); walk(leg_left_calf_1, 0.5f, 0.6f, true, 2.8F, 0.2f, limbSwing, limbSwingAmount); } // Sitting Animation if (camel.sitProgress > 0) { this.progressPosition(body_main, camel.sitProgress, 0F, 17.3F, 0F, 40); this.progressRotation(neck, camel.sitProgress, (float) Math.toRadians(-54.78), 0, 0, 40); this.progressRotation(arm_right, camel.sitProgress, (float) Math.toRadians(-10.43F), 0, 0, 40); this.progressPosition(arm_right_2, camel.sitProgress, 0F, 7F, -1.7F, 40); this.progressRotation(arm_right_2, camel.sitProgress, (float) Math.toRadians(104.35), (float) Math.toRadians(2.61), 0.0F, 40); this.progressRotation(arm_left, camel.sitProgress, (float) Math.toRadians(-10.43F), 0, 0, 40); this.progressPosition(arm_left_2, camel.sitProgress, 0F, 7F, -1.7F, 40); this.progressRotation(arm_left_2, camel.sitProgress, (float) Math.toRadians(104.35), (float) Math.toRadians(-2.61), 0.0F, 40); this.progressRotation(leg_right_calf, camel.sitProgress, (float) Math.toRadians(18.26), 0.0F, 0.0F, 40); this.progressRotation(leg_right_calf_1, camel.sitProgress, (float) Math.toRadians(-112.17), 0.0F, 0.0F, 40); this.progressRotation(leg_left_calf, camel.sitProgress, (float) Math.toRadians(18.26), 0.0F, 0.0F, 40); this.progressRotation(leg_left_calf_1, camel.sitProgress, (float) Math.toRadians(-112.17), 0.0F, 0.0F, 40); } // Sleeping Animation if (camel.sleepProgress > 0) { this.progressPosition(body_main, camel.sleepProgress, 0F, 17.3F, 0F, 40); this.progressRotation(neck, camel.sleepProgress, (float) Math.toRadians(39.13), 0, 0, 40); this.progressPosition(head_main, camel.sleepProgress, 0F, 2.6F, -8.3F, 40); this.progressRotation(head_main, camel.sleepProgress, (float) Math.toRadians(-33.91), 0.0F, 0.0F, 40); this.progressRotation(arm_right, camel.sleepProgress, (float) Math.toRadians(-10.43F), 0, 0, 40); this.progressPosition(arm_right_2, camel.sleepProgress, 0F, 7F, -1.7F, 40); this.progressRotation(arm_right_2, camel.sleepProgress, (float) Math.toRadians(104.35), (float) Math.toRadians(2.61), 0.0F, 40); this.progressRotation(arm_left, camel.sleepProgress, (float) Math.toRadians(-10.43F), 0, 0, 40); this.progressPosition(arm_left_2, camel.sleepProgress, 0F, 7F, -1.7F, 40); this.progressRotation(arm_left_2, camel.sleepProgress, (float) Math.toRadians(104.35), (float) Math.toRadians(-2.61), 0.0F, 40); this.progressRotation(leg_right_calf, camel.sleepProgress, (float) Math.toRadians(18.26), 0.0F, 0.0F, 40); this.progressRotation(leg_right_calf_1, camel.sleepProgress, (float) Math.toRadians(-112.17), 0.0F, 0.0F, 40); this.progressRotation(leg_left_calf, camel.sleepProgress, (float) Math.toRadians(18.26), 0.0F, 0.0F, 40); this.progressRotation(leg_left_calf_1, camel.sleepProgress, (float) Math.toRadians(-112.17), 0.0F, 0.0F, 40); } } }
12,706
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelGiantSalamander.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelGiantSalamander.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.amphibian.EntityGiantSalamander; public class ModelGiantSalamander extends AdvancedEntityModel<EntityGiantSalamander> { public AdvancedModelBox body_main; public AdvancedModelBox body_torso; public AdvancedModelBox tail_1; public AdvancedModelBox leg_left_1; public AdvancedModelBox leg_right_1; public AdvancedModelBox arm_left_1; public AdvancedModelBox arm_right_1; public AdvancedModelBox head_main; public AdvancedModelBox head_jaw; public AdvancedModelBox head_face; public AdvancedModelBox tail_2; private final ModelAnimator animator; public ModelGiantSalamander() { this.texWidth = 64; this.texHeight = 32; this.arm_right_1 = new AdvancedModelBox(this, 24, 0); this.arm_right_1.mirror = true; this.arm_right_1.setRotationPoint(-2.0F, 0.2F, -3.0F); this.arm_right_1.addBox(-1.5F, -1.0F, -4.0F, 3, 2, 4, 0.0F); this.setRotateAngle(arm_right_1, 0.22759093446006054F, 1.1838568316277536F, 0.0F); this.arm_left_1 = new AdvancedModelBox(this, 24, 0); this.arm_left_1.setRotationPoint(2.0F, 0.2F, -3.0F); this.arm_left_1.addBox(-1.5F, -1.0F, -4.0F, 3, 2, 4, 0.0F); this.setRotateAngle(arm_left_1, 0.22759093446006054F, -1.0471975511965976F, 0.0F); this.tail_2 = new AdvancedModelBox(this, 42, 8); this.tail_2.setRotationPoint(0.0F, 0.0F, 4.0F); this.tail_2.addBox(-1.0F, -2.0F, 0.0F, 2, 4, 7, 0.0F); this.body_main = new AdvancedModelBox(this, 0, 10); this.body_main.setRotationPoint(0.0F, 22.3F, 0.0F); this.body_main.addBox(-2.5F, -1.5F, 0.0F, 5, 3, 7, 0.0F); this.leg_left_1 = new AdvancedModelBox(this, 24, 8); this.leg_left_1.setRotationPoint(1.5F, 0.2F, 5.0F); this.leg_left_1.addBox(-1.5F, -1.0F, -4.0F, 3, 2, 4, 0.0F); this.setRotateAngle(leg_left_1, 0.22759093446006054F, -2.0943951023931953F, 0.0F); this.tail_1 = new AdvancedModelBox(this, 42, 0); this.tail_1.setRotationPoint(0.0F, 0.01F, 7.0F); this.tail_1.addBox(-1.5F, -1.5F, 0.0F, 3, 3, 4, 0.0F); this.head_main = new AdvancedModelBox(this, 0, 20); this.head_main.setRotationPoint(0.0F, -0.4F, -6.0F); this.head_main.addBox(-3.0F, -1.5F, -2.5F, 6, 3, 3, 0.0F); this.setRotateAngle(head_main, 0.136659280431156F, 0.0F, 0.0F); this.body_torso = new AdvancedModelBox(this, 0, 0); this.body_torso.setRotationPoint(0.0F, 0.0F, 0.0F); this.body_torso.addBox(-2.5F, -1.5F, -7.0F, 5, 3, 7, 0.0F); this.leg_right_1 = new AdvancedModelBox(this, 24, 8); this.leg_right_1.mirror = true; this.leg_right_1.setRotationPoint(-1.5F, 0.2F, 5.0F); this.leg_right_1.addBox(-1.5F, -1.0F, -4.0F, 3, 2, 4, 0.0F); this.setRotateAngle(leg_right_1, 0.22759093446006054F, 2.0943951023931953F, 0.0F); this.head_jaw = new AdvancedModelBox(this, 18, 25); this.head_jaw.setRotationPoint(0.0F, 0.5F, -2.5F); this.head_jaw.addBox(-3.0F, 0.0F, -3.0F, 6, 1, 3, 0.0F); this.head_face = new AdvancedModelBox(this, 18, 20); this.head_face.setRotationPoint(0.0F, -0.5F, -1.5F); this.head_face.addBox(-3.0F, -1.0F, -4.0F, 6, 2, 3, 0.0F); this.body_torso.addChild(this.arm_right_1); this.body_torso.addChild(this.arm_left_1); this.tail_1.addChild(this.tail_2); this.body_main.addChild(this.leg_left_1); this.body_main.addChild(this.tail_1); this.body_torso.addChild(this.head_main); this.body_main.addChild(this.body_torso); this.body_main.addChild(this.leg_right_1); this.head_main.addChild(this.head_jaw); this.head_main.addChild(this.head_face); animator = ModelAnimator.create(); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( body_main, body_torso, arm_left_1, arm_right_1, leg_left_1, leg_right_1, tail_1, tail_2, head_main, head_face, head_jaw ); } private void animate(IAnimatedEntity entityIn) { animator.update(entityIn); animator.setAnimation(EntityGiantSalamander.ATTACK_SWALLOW); animator.startKeyframe(5); this.rotate(animator, head_main, -5.22F, 15.65F, -20.87F); this.rotate(animator, head_jaw, 57.39F, 0, 0); this.rotate(animator, head_face, -44.35F, 0, 0); animator.endKeyframe(); animator.startKeyframe(5); this.rotate(animator, head_main, -5.22F, -5.22F, 10.43F); this.rotate(animator, head_jaw, 57.39F, 0, 0); this.rotate(animator, head_face, -44.35F, 0, 0); animator.endKeyframe(); animator.resetKeyframe(5); } public void setupAnim(EntityGiantSalamander salamander, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { resetToDefaultPose(); animate(salamander); float globalSpeed = 0.8f; float globalDegree = 1.0f; limbSwingAmount = Math.min(0.6F, limbSwingAmount); // Breathing Animation this.body_main.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.body_torso.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.head_face.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.head_jaw.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); this.head_main.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); // Head Tracking Animation if (!salamander.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 2, head_main); } // Pitch/Yaw handler if (salamander.isInWater() && !salamander.isOnGround()) { this.setRotateAngle(body_main, salamander.getXRot() * ((float) Math.PI / 180F), 0, 0); } this.body_torso.rotateAngleY = Mth.rotLerp((float) 0.05, this.body_torso.rotateAngleY, salamander.offset); this.tail_1.rotateAngleY = Mth.rotLerp((float) 0.05, this.tail_1.rotateAngleY, -1F * salamander.offset); this.tail_2.rotateAngleY = Mth.rotLerp((float) 0.05, this.tail_2.rotateAngleY, -2F * salamander.offset); // Movement Animation AdvancedModelBox[] bodyParts = new AdvancedModelBox[]{head_main, body_torso, body_main, tail_1, tail_2}; chainSwing(bodyParts, globalSpeed * 1.4F, globalDegree * 1.2F, -4, limbSwing, limbSwingAmount * 0.3F); float onGround = Math.min(0.8F, limbSwingAmount * (salamander.isOnGround() ? 2 : 1)); if (salamander.isInWater()) { flap(arm_left_1, globalSpeed, globalDegree, false, 0.8F, 1f, limbSwing, limbSwingAmount); flap(leg_left_1, globalSpeed, globalDegree * 0.8f, false, 1.6F, 1f, limbSwing, limbSwingAmount); flap(arm_right_1, globalSpeed, globalDegree, false, 2.4F, 1f, limbSwing, limbSwingAmount); flap(leg_right_1, globalSpeed, globalDegree * 0.8f, false, 3.2F, 1f, limbSwing, limbSwingAmount); flap(body_main, globalSpeed / 2, globalDegree * 1.2f, false, 0, 0.1f, limbSwing / 2, limbSwingAmount); swing(body_main, globalSpeed / 2, globalDegree * 1.2f, false, 0.8F, 0.1f, limbSwing / 3, limbSwingAmount); chainWave(new AdvancedModelBox[]{head_main, body_torso, body_main}, globalSpeed * 0.8F, globalDegree, -4, limbSwing, limbSwingAmount * 0.2F); } else { swing(arm_left_1, globalSpeed, globalDegree * 2f, false, 0.8F, 1f, limbSwing, onGround); swing(leg_left_1, globalSpeed, globalDegree * 1.8f, false, 1.6F, 1f, limbSwing, onGround); swing(arm_right_1, globalSpeed, globalDegree * 2f, false, 2.4F, 1f, limbSwing, onGround); swing(leg_right_1, globalSpeed, globalDegree * 1.8f, false, 3.2F, 1f, limbSwing, onGround); } // Swimming Animation if (salamander.swimProgress > 0) { this.progressRotation(arm_right_1, salamander.swimProgress, (float) Math.toRadians(-20.87F), (float) Math.toRadians(172.1F), (float) Math.toRadians(-78.26), 20); this.progressRotation(arm_left_1, salamander.swimProgress, (float) Math.toRadians(-20.87F), (float) Math.toRadians(-172.1F), (float) Math.toRadians(78.26), 20); this.progressRotation(leg_right_1, salamander.swimProgress, (float) Math.toRadians(-15.65), (float) Math.toRadians(174.7), (float) Math.toRadians(-88.7), 20); this.progressRotation(leg_left_1, salamander.swimProgress, (float) Math.toRadians(-15.65), (float) Math.toRadians(-174.7), (float) Math.toRadians(88.7), 20); } } }
9,567
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelRhino.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelRhino.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import untamedwilds.entity.mammal.EntityRhino; public class ModelRhino extends AdvancedEntityModel<EntityRhino> { private final AdvancedModelBox body_belly; private final AdvancedModelBox body_front; private final AdvancedModelBox leg_right; private final AdvancedModelBox leg_left; private final AdvancedModelBox head_neck; private final AdvancedModelBox arm_right_1; private final AdvancedModelBox arm_left_1; private final AdvancedModelBox head_face; private final AdvancedModelBox ear_right; private final AdvancedModelBox ear_left; private final AdvancedModelBox horn_front; private final AdvancedModelBox horn_front_small; private final AdvancedModelBox horn_back; private final AdvancedModelBox eye_left; private final AdvancedModelBox eye_right; private final AdvancedModelBox arm_right_2; private final AdvancedModelBox arm_left_2; private final AdvancedModelBox leg_right_2; private final AdvancedModelBox leg_left_2; private final ModelAnimator animator; public ModelRhino() { this.texWidth = 128; this.texHeight = 64; this.horn_back = new AdvancedModelBox(this, 0, 0); this.horn_back.setRotationPoint(0.0F, -2.6F, -4.7F); this.horn_back.addBox(-1.0F, -4.0F, -1.5F, 2, 4, 3, 0.0F); this.setRotateAngle(horn_back, 0.045553093477052F, 0.0F, 0.0F); this.horn_front_small = new AdvancedModelBox(this, 11, 0); this.horn_front_small.setRotationPoint(0.0F, -3.6F, -9.1F); this.horn_front_small.addBox(-1.0F, -4.0F, -1.5F, 2, 4, 3, 0.0F); this.setRotateAngle(horn_front_small, 0.18203784F, 0.0F, 0.0F); this.arm_left_1 = new AdvancedModelBox(this, 50, 0); this.arm_left_1.setRotationPoint(4.0F, 6.0F, -6.0F); this.arm_left_1.addBox(-2.5F, 0.0F, -3.0F, 5, 7, 6, 0.0F); this.setRotateAngle(arm_left_1, 0.36425021489121656F, 0.0F, 0.09110618695410334F); this.horn_front = new AdvancedModelBox(this, 0, 10); this.horn_front.setRotationPoint(0.0F, -3.6F, -9.0F); this.horn_front.addBox(-1.0F, -8.0F, -1.5F, 2, 8, 3, 0.0F); this.setRotateAngle(horn_front, 0.136659280431156F, 0.0F, 0.0F); this.leg_left = new AdvancedModelBox(this, 72, 28); this.leg_left.setRotationPoint(4.0F, 6.0F, 15.0F); this.leg_left.addBox(-2.5F, -2.0F, -3.5F, 5, 7, 7, 0.0F); this.setRotateAngle(leg_left, 0.31869712141416456F, 0.0F, 0.091106186954104F); this.leg_left_2 = new AdvancedModelBox(this, 76, 42); this.leg_left_2.setRotationPoint(-0.01F, 3.0F, 0.5F); this.leg_left_2.addBox(-2.5F, 0.0F, -3.0F, 5, 7, 6, 0.0F); this.setRotateAngle(leg_left_2, -0.31869712141416456F, 0.0F, -0.091106186954104F); this.ear_right = new AdvancedModelBox(this, 0, 36); this.ear_right.setRotationPoint(-2.5F, -4.0F, -5.0F); this.ear_right.addBox(-1.0F, -5.0F, -0.5F, 2, 5, 1, 0.0F); this.setRotateAngle(ear_right, 0.0F, 0.22759093446006054F, -0.5462880558742251F); this.eye_left = new AdvancedModelBox(this, 48, 44); this.eye_left.setRotationPoint(3.01F, -1.5F, -5.0F); this.eye_left.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.arm_left_2 = new AdvancedModelBox(this, 28, 36); this.arm_left_2.setRotationPoint(-0.01F, 6.3F, 0.5F); this.arm_left_2.addBox(-2.5F, 0.0F, -3.0F, 5, 5, 5, 0.0F); this.setRotateAngle(arm_left_2, -0.136659280431156F, 0.0F, -0.091106186954104F); this.arm_right_1 = new AdvancedModelBox(this, 50, 0); this.arm_right_1.mirror = true; this.arm_right_1.setRotationPoint(-4.0F, 6.0F, -6.0F); this.arm_right_1.addBox(-2.5F, 0.0F, -3.0F, 5, 7, 6, 0.0F); this.setRotateAngle(arm_right_1, 0.3642502148912149F, 0.0F, -0.09110618695410382F); this.arm_right_2 = new AdvancedModelBox(this, 28, 36); this.arm_right_2.mirror = true; this.arm_right_2.setRotationPoint(0.01F, 6.3F, 0.5F); this.arm_right_2.addBox(-2.5F, 0.0F, -3.0F, 5, 5, 5, 0.0F); this.setRotateAngle(arm_right_2, -0.13665928043115597F, 0.0F, 0.091106186954104F); this.leg_right = new AdvancedModelBox(this, 72, 28); this.leg_right.mirror = true; this.leg_right.setRotationPoint(-4.0F, 6.0F, 15.0F); this.leg_right.addBox(-2.5F, -2.0F, -3.5F, 5, 7, 7, 0.0F); this.setRotateAngle(leg_right, 0.31869712141416456F, 0.0F, -0.091106186954104F); this.body_front = new AdvancedModelBox(this, 72, 0); this.body_front.setRotationPoint(0.0F, 0.0F, 0.0F); this.body_front.addBox(-8.0F, -8.0F, -12.0F, 16, 16, 12, 0.0F); this.setRotateAngle(body_front, -0.22759093446006054F, 0.0F, 0.0F); this.leg_right_2 = new AdvancedModelBox(this, 76, 42); this.leg_right_2.mirror = true; this.leg_right_2.setRotationPoint(0.01F, 3.0F, 0.5F); this.leg_right_2.addBox(-2.5F, 0.0F, -3.0F, 5, 7, 6, 0.0F); this.setRotateAngle(leg_right_2, -0.31869712141416456F, 0.0F, 0.091106186954104F); this.body_belly = new AdvancedModelBox(this, 0, 0); this.body_belly.setRotationPoint(0.0F, 8.5F, 0.0F); this.body_belly.addBox(-7.0F, -7.0F, -3.0F, 14, 14, 22, 0.0F); this.eye_right = new AdvancedModelBox(this, 44, 44); this.eye_right.setRotationPoint(-3.01F, -1.5F, -5.0F); this.eye_right.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.head_neck = new AdvancedModelBox(this, 0, 36); this.head_neck.setRotationPoint(0.0F, -1.0F, -11.0F); this.head_neck.addBox(-4.0F, -5.0F, -8.0F, 8, 10, 12, 0.0F); this.setRotateAngle(head_neck, 0.5462880558742241F, 0.0F, 0.0F); this.head_face = new AdvancedModelBox(this, 40, 36); this.head_face.setRotationPoint(0.0F, 1.0F, -6.0F); this.head_face.addBox(-3.0F, -4.0F, -11.0F, 6, 8, 12, 0.0F); this.setRotateAngle(head_face, 0.22759093446006054F, 0.0F, 0.0F); this.ear_left = new AdvancedModelBox(this, 0, 36); this.ear_left.mirror = true; this.ear_left.setRotationPoint(2.5F, -4.0F, -5.0F); this.ear_left.addBox(-1.0F, -5.0F, -0.5F, 2, 5, 1, 0.0F); this.setRotateAngle(ear_left, 0.0F, -0.22759093446006054F, 0.5462880558742251F); this.head_face.addChild(this.horn_back); this.body_front.addChild(this.arm_left_1); this.head_face.addChild(this.horn_front); this.head_face.addChild(this.horn_front_small); this.body_belly.addChild(this.leg_left); this.leg_left.addChild(this.leg_left_2); this.head_neck.addChild(this.ear_right); this.head_face.addChild(this.eye_left); this.arm_left_1.addChild(this.arm_left_2); this.body_front.addChild(this.arm_right_1); this.arm_right_1.addChild(this.arm_right_2); this.body_belly.addChild(this.leg_right); this.body_belly.addChild(this.body_front); this.leg_right.addChild(this.leg_right_2); this.head_face.addChild(this.eye_right); this.body_front.addChild(this.head_neck); this.head_neck.addChild(this.head_face); this.head_neck.addChild(this.ear_left); animator = ModelAnimator.create(); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(body_belly); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of(body_belly, body_front, leg_right, leg_left, head_neck, arm_right_1, arm_left_1, head_face, ear_right, ear_left, horn_front, horn_back, eye_left, eye_right, arm_right_2, arm_left_2, leg_right_2, leg_left_2, horn_front_small ); } private void animate(IAnimatedEntity entityIn) { EntityRhino rhino = (EntityRhino) entityIn; animator.update(rhino); animator.setAnimation(EntityRhino.ATTACK_THREATEN); for (int i = 0; i < 2; i++) { animator.startKeyframe(12); this.rotate(animator, body_front, 0, 0, 7.83F); this.rotate(animator, head_neck, 7.83F, 0, -13.04F); this.rotate(animator, arm_right_2, 31.31F, 0, 0); animator.move(arm_left_1, 0, -0.6F, 0); this.rotate(animator, arm_left_1, 0, 0, -7.83F); animator.move(arm_right_1, 0, -0.5F, 0); this.rotate(animator, arm_right_1, -46.96F, 0, -5.21F); animator.endKeyframe(); animator.startKeyframe(9); this.rotate(animator, body_front, 0, 0, -13.05F); this.rotate(animator, head_neck, 7.83F, 0, 26.08F); this.rotate(animator, arm_right_2, 31.31F, 0, 0); animator.move(arm_left_1, 0, 0.5F, 0); this.rotate(animator, arm_left_1, 0, 0, 13.04F); animator.move(arm_right_1, 0, 0.5F, 0); this.rotate(animator, arm_right_1, 54.79F, 0, 10.43F); animator.endKeyframe(); } animator.resetKeyframe(8); animator.setAnimation(EntityRhino.ATTACK_GORE); animator.startKeyframe(6); this.rotate(animator, head_neck, 31.31F, 0, 26.08F); animator.endKeyframe(); animator.startKeyframe(4); this.rotate(animator, head_neck, -26.08F, 0, -46.96F); animator.endKeyframe(); animator.resetKeyframe(4); } public void setupAnim(EntityRhino rhino, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { this.resetToDefaultPose(); animate(rhino); float globalSpeed = 1.5f; float globalDegree = 1f; float f = limbSwing / 2; limbSwingAmount = Math.min(0.4F, limbSwingAmount); // Breathing Animation this.body_belly.setScale((float) (1.0F + Math.sin(ageInTicks / 20) * 0.08F), (float) (1.0F + Math.sin(ageInTicks / 16) * 0.08F), 1.0F); this.body_front.setScale((float) (1.0F + Math.sin(ageInTicks / 20) * 0.08F), (float) (1.0F + Math.sin(ageInTicks / 16) * 0.08F), 1.0F); bob(body_belly, 0.4F * globalSpeed, 0.1F, false, ageInTicks / 20, 2); bob(arm_right_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(arm_left_1, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_right, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_left, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); walk(head_neck, 0.4f * globalSpeed, 0.03f, false, 2.8F, 0.06F, ageInTicks / 20, 2); // Blinking Animation if (!rhino.shouldRenderEyes()) { this.eye_right.setRotationPoint(-2F, -2.0F, -4.0F); this.eye_left.setRotationPoint(2F, -2.0F, -4.0F); } // Head Tracking Animation if (!rhino.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 3, head_neck); this.faceTarget(netHeadYaw, headPitch, 3, head_face); } // Movement Animation if (rhino.canMove()) { bob(body_belly, 0.8f * globalSpeed, 0.6f * globalDegree, true, f, limbSwingAmount); walk(head_neck, 0.8f * globalSpeed, 0.2f * globalDegree, false, 0, 0, f, limbSwingAmount); walk(head_face, 0.8f * globalSpeed, 0.15f * globalDegree, true, 0, 0, f, limbSwingAmount); walk(arm_right_1, -0.8f * globalSpeed, 1.4f * globalDegree, true, 0F, 1.4f, f, limbSwingAmount); walk(arm_right_2, -0.8f * globalSpeed, 1.4f * globalDegree, false, -1F, 1.4f, f, limbSwingAmount * 1.2f); walk(arm_left_1, -0.8f * globalSpeed, 1.4f * globalDegree, true, 2F, 1.4f, f, limbSwingAmount); walk(arm_left_2, -0.8f * globalSpeed, 1.4f * globalDegree, false, 1F, 1.4f, f, limbSwingAmount * 1.2f); walk(leg_right, 0.8f * globalSpeed, 1.4f * globalDegree, false, 2.8F, 0, f, limbSwingAmount); walk(leg_right_2, 0.8f * globalSpeed, 1.4f * globalDegree, true, 1.8F, 0, f, limbSwingAmount); walk(leg_left, 0.8f * globalSpeed, 1.4f * globalDegree, false, 0.8F, 0, f, limbSwingAmount); walk(leg_left_2, 0.8f * globalSpeed, 1.4f * globalDegree, true, -0.2F, 0, f, limbSwingAmount); } // Sitting Animation if (rhino.sitProgress > 0) { this.progressPosition(body_belly, rhino.sitProgress, 0.0F, 17.5F, 0.0F, 40); this.progressRotation(body_belly, rhino.sitProgress, 0.0F, 0.0F, (float) Math.toRadians(7.83F), 40); this.progressPosition(arm_right_1, rhino.sitProgress, -6.0F, 6.0F, -9.0F, 40); this.progressRotation(arm_right_1, rhino.sitProgress, (float) Math.toRadians(-104.3F), (float) Math.toRadians(23.48F), (float) Math.toRadians(-96.52F), 40); this.progressRotation(arm_right_2, rhino.sitProgress, (float) Math.toRadians(80.87F), 0.0F, (float) Math.toRadians(5.22F), 40); this.progressPosition(arm_left_1, rhino.sitProgress, 6.0F, 6.0F, -9.0F, 40); this.progressRotation(arm_left_1, rhino.sitProgress, (float) Math.toRadians(-96.52F), 0.0F, (float) Math.toRadians(5.22F), 40); this.progressRotation(arm_left_2, rhino.sitProgress, (float) Math.toRadians(86.09F), 0.0F, (float) Math.toRadians(-5.22F), 40); this.progressPosition(leg_right, rhino.sitProgress, -6.0F, 6.0F, 15.0F, 40); this.progressRotation(leg_right, rhino.sitProgress, (float) Math.toRadians(-106.9F), (float) Math.toRadians(13.04F), (float) Math.toRadians(-2.61F), 40); this.progressRotation(leg_right_2, rhino.sitProgress, (float) Math.toRadians(15.65F), 0.0F, (float) Math.toRadians(5.22F), 40); this.progressRotation(leg_left, rhino.sitProgress, (float) Math.toRadians(-13.04F), (float) Math.toRadians(5.22F), (float) Math.toRadians(88.70F), 40); } // Sleeping Animation if (rhino.sleepProgress > 0) { this.progressPosition(body_belly, rhino.sleepProgress, 0.0F, 17.5F, 0.0F, 40); this.progressRotation(body_belly, rhino.sleepProgress, 0.0F, 0.0F, (float)Math.toRadians(7.83F), 40); this.progressPosition(arm_right_1, rhino.sleepProgress, -6.0F, 6.0F, -9.0F, 40); this.progressRotation(arm_right_1, rhino.sleepProgress, (float)Math.toRadians(-104.3F), (float)Math.toRadians(23.48F), (float)Math.toRadians(-96.52F), 40); this.progressRotation(arm_right_2, rhino.sleepProgress, (float)Math.toRadians(80.87F), 0.0F, (float)Math.toRadians(5.22F), 40); this.progressPosition(arm_left_1, rhino.sleepProgress, 6.0F, 6.0F, -9.0F, 40); this.progressRotation(arm_left_1, rhino.sleepProgress, (float)Math.toRadians(-96.52F), 0.0F, (float)Math.toRadians(5.22F), 40); this.progressRotation(arm_left_2, rhino.sleepProgress, (float)Math.toRadians(86.09F), 0.0F, (float)Math.toRadians(-5.22F), 40); this.progressPosition(leg_right, rhino.sleepProgress, -6.0F, 6.0F, 15.0F, 40); this.progressRotation(leg_right, rhino.sleepProgress, (float)Math.toRadians(-106.9F), (float)Math.toRadians(13.04F), (float)Math.toRadians(-2.61F), 40); this.progressRotation(leg_right_2, rhino.sleepProgress, (float)Math.toRadians(15.65F), 0.0F, (float)Math.toRadians(5.22F), 40); this.progressRotation(leg_left, rhino.sleepProgress, (float)Math.toRadians(-13.04F), (float)Math.toRadians(5.22F), (float)Math.toRadians(88.70F), 40); } } }
15,896
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelSunfish.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelSunfish.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import untamedwilds.entity.fish.EntitySunfish; public class ModelSunfish extends AdvancedEntityModel<EntitySunfish> { public AdvancedModelBox body_main; public AdvancedModelBox body_head; public AdvancedModelBox body_tail; public AdvancedModelBox body_fin_right; public AdvancedModelBox body_fin_left; public AdvancedModelBox body_tail_fin; public AdvancedModelBox body_fin_top; public AdvancedModelBox body_fin_bottom; public ModelSunfish() { this.texWidth = 128; this.texHeight = 64; this.body_main = new AdvancedModelBox(this, 0, 0); this.body_main.setRotationPoint(0.0F, 11.0F, 0.0F); this.body_main.addBox(-3.0F, -13.0F, -8.0F, 6, 26, 16, 0.0F); this.body_fin_right = new AdvancedModelBox(this, 0, 0); this.body_fin_right.setRotationPoint(-3.0F, -2.0F, -4.0F); this.body_fin_right.addBox(0.0F, -2.0F, 0.0F, 0, 4, 5, 0.0F); this.setRotateAngle(body_fin_right, 0.0F, -0.5462880558742251F, 0.0F); this.body_tail_fin = new AdvancedModelBox(this, 104, 0); this.body_tail_fin.setRotationPoint(0.0F, 0.0F, 8.0F); this.body_tail_fin.addBox(-1.0F, -11.0F, 0.0F, 2, 22, 5, 0.0F); this.body_fin_top = new AdvancedModelBox(this, 82, 32); this.body_fin_top.setRotationPoint(0.0F, -10.0F, 6.0F); this.body_fin_top.addBox(-1.0F, -20.0F, -4.0F, 2, 20, 8, 0.0F); this.setRotateAngle(body_fin_top, -0.22759093446006054F, 0.0F, 0.0F); this.body_fin_left = new AdvancedModelBox(this, 0, 0); this.body_fin_left.setRotationPoint(3.0F, -2.0F, -4.0F); this.body_fin_left.addBox(0.0F, -2.0F, 0.0F, 0, 4, 5, 0.0F); this.setRotateAngle(body_fin_left, 0.0F, 0.5462880558742251F, 0.0F); this.body_head = new AdvancedModelBox(this, 44, 0); this.body_head.setRotationPoint(0.0F, 0.0F, -9.0F); this.body_head.addBox(-2.5F, -9.0F, -6.0F, 5, 18, 7, 0.0F); this.body_tail = new AdvancedModelBox(this, 78, 0); this.body_tail.setRotationPoint(0.0F, 0.0F, 8.0F); this.body_tail.addBox(-2.5F, -11.0F, 0.0F, 5, 22, 8, 0.0F); this.body_fin_bottom = new AdvancedModelBox(this, 104, 32); this.body_fin_bottom.setRotationPoint(0.0F, 10.0F, 6.0F); this.body_fin_bottom.addBox(-1.0F, 0.0F, -4.0F, 2, 20, 8, 0.0F); this.setRotateAngle(body_fin_bottom, 0.22759093446006054F, 0.0F, 0.0F); this.body_main.addChild(this.body_fin_right); this.body_tail.addChild(this.body_tail_fin); this.body_tail.addChild(this.body_fin_top); this.body_main.addChild(this.body_fin_left); this.body_main.addChild(this.body_head); this.body_main.addChild(this.body_tail); this.body_tail.addChild(this.body_fin_bottom); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( body_main, body_head, body_tail, body_fin_right, body_fin_left, body_tail_fin, body_fin_top, body_fin_bottom ); } public void setupAnim(EntitySunfish sunfish, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { float f = ageInTicks - (float)sunfish.tickCount / 10; resetToDefaultPose(); if (!sunfish.isInWater()) { body_main.defaultPositionY =+ 20; this.setRotateAngle(body_main, 0, 0, (float)Math.toRadians(90D)); } else { this.setRotateAngle(body_main, netHeadYaw * 2 * ((float)Math.PI / 180F), headPitch * 2 * ((float)Math.PI / 180F), 0); progressRotation(body_main, sunfish.baskProgress, 0, 0, (float)Math.toRadians(90D), 100); } float globalSpeed = 0.6f; float globalDegree = 0.6f; flap(body_fin_bottom, globalSpeed * 0.4F, globalDegree * 0.8f, true, 0, 0, f, 1F); flap(body_fin_top, globalSpeed * 0.4F, globalDegree * 0.8f, false, 0, 0, f , 1F); swing(body_tail_fin, globalSpeed * 0.4F, globalDegree * 0.8f, false, 0, 0, f, 0.6F); flap(body_fin_left, globalSpeed, globalDegree * 0.8f, true, 0, 0.2f, f / 6, 1F); swing(body_fin_left, globalSpeed, globalDegree * 0.8f, false, 0, 0.2f, f / 6, 0.6F); flap(body_fin_right, globalSpeed, globalDegree * 0.8f, false, 0, 0.2f, f / 6, 1F); swing(body_fin_right, globalSpeed, globalDegree * 0.8f, true, 0, 0.2f, f / 6, 0.6F); } }
4,937
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelTurtleSoftshell.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelTurtleSoftshell.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.reptile.EntitySoftshellTurtle; public class ModelTurtleSoftshell extends AdvancedEntityModel<EntitySoftshellTurtle> { public AdvancedModelBox main_body; public AdvancedModelBox body_shell; public AdvancedModelBox hand_right; public AdvancedModelBox leg_right; public AdvancedModelBox neck; public AdvancedModelBox hand_left; public AdvancedModelBox leg_left; public AdvancedModelBox body_tail_short; public AdvancedModelBox main_head; public AdvancedModelBox head_nose; public ModelTurtleSoftshell() { this.texWidth = 64; this.texHeight = 32; this.neck = new AdvancedModelBox(this, 20, 0); this.neck.setRotationPoint(0.0F, 0.0F, -0.01F); this.neck.addBox(-1.0F, -1.0F, -4.0F, 2, 2, 4, 0.0F); this.setRotateAngle(neck, 0.0F, 0.0F, 0.0F); this.leg_left = new AdvancedModelBox(this, 26, 14); this.leg_left.mirror = true; this.leg_left.setRotationPoint(3.0F, 0.51F, 2.0F); this.leg_left.addBox(-1.0F, -0.5F, -1.0F, 5, 1, 3, 0.0F); this.setRotateAngle(leg_left, 0.0F, -1.0927506446736497F, 0.0F); this.body_tail_short = new AdvancedModelBox(this, 8, 22); this.body_tail_short.setRotationPoint(0.0F, 0.0F, 2.0F); this.body_tail_short.addBox(-0.5F, 0.0F, 0.0F, 1, 1, 4, 0.0F); this.main_head = new AdvancedModelBox(this, 32, 0); this.main_head.setRotationPoint(0.0F, -0.2F, -3.41F); this.main_head.addBox(-1.5F, -1.0F, -3.0F, 3, 2, 4, 0.0F); this.setRotateAngle(main_head, 0.0F, 0.0F, 0.0F); this.body_shell = new AdvancedModelBox(this, 0, 11); this.body_shell.setRotationPoint(0.0F, -0.4F, 0.0F); this.body_shell.addBox(-4.0F, -1.0F, -5.0F, 8, 1, 10, 0.0F); this.setRotateAngle(body_shell, -0.045553093477052F, 0.0F, 0.0F); this.leg_right = new AdvancedModelBox(this, 26, 14); this.leg_right.setRotationPoint(-3.0F, 0.51F, 2.0F); this.leg_right.addBox(-4.0F, -0.5F, -1.0F, 5, 1, 3, 0.0F); this.setRotateAngle(leg_right, 0.0F, 1.0927506446736497F, 0.0F); this.hand_right = new AdvancedModelBox(this, 26, 8); this.hand_right.setRotationPoint(-2.0F, 0.7F, -3.0F); this.hand_right.addBox(-4.0F, -0.5F, -2.0F, 5, 1, 3, 0.0F); this.setRotateAngle(hand_right, 0.0F, -0.3490658503988659F, 0.0F); this.head_nose = new AdvancedModelBox(this, 28, 0); this.head_nose.setRotationPoint(0.0F, -0.49F, -3.0F); this.head_nose.addBox(-1F, -0.5F, -1.0F, 2, 1, 2, 0.0F); this.setRotateAngle(head_nose, 0.091106186954104F, 0.0F, 0.0F); this.main_body = new AdvancedModelBox(this, 0, 0); this.main_body.setRotationPoint(0.0F, 23.0F, 0.0F); this.main_body.addBox(-3.0F, -2.0F, -4.0F, 6, 3, 7, 0.0F); this.hand_left = new AdvancedModelBox(this, 26, 8); this.hand_left.mirror = true; this.hand_left.setRotationPoint(2.0F, 0.7F, -3.0F); this.hand_left.addBox(-1.0F, -0.5F, -2.0F, 5, 1, 3, 0.0F); this.setRotateAngle(hand_left, 0.0F, 0.3490658503988659F, 0.0F); this.main_body.addChild(this.neck); this.main_body.addChild(this.leg_left); this.main_body.addChild(this.body_tail_short); this.neck.addChild(this.main_head); this.main_body.addChild(this.body_shell); this.main_body.addChild(this.leg_right); this.main_body.addChild(this.hand_right); this.main_head.addChild(this.head_nose); this.main_body.addChild(this.hand_left); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.main_body); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of(main_body, hand_left, hand_right, leg_left, leg_right, neck, main_head ); } public void setupAnim(EntitySoftshellTurtle turtle, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { resetToDefaultPose(); limbSwing = ageInTicks; float globalSpeed = 1.2f; float globalDegree = 0.6f; if (limbSwingAmount > 0.5) { limbSwingAmount = 0.5F; } // Basking animation (it just raises the head up) if (turtle.extendNeckProgress != 0) { progressPosition(neck, turtle.extendNeckProgress, 0.0F, 0.0F, -4.01F, 100); progressRotation(neck, turtle.extendNeckProgress, -0.5009094953223726F, 0, 0.0F, 100); progressRotation(main_head, turtle.extendNeckProgress, 0.36425021489121656F, 0, 0.0F, 100); } /*if (turtle.lurkingProgress != 0) { progressRotation(main_body, turtle.lurkingProgress, (float) Math.toRadians(-28.70F), 0.0F, 0.0F, 60); progressPosition(neck, turtle.lurkingProgress, 0.0F, 0.0F, -4.01F, 60); progressRotation(neck, turtle.lurkingProgress, (float) Math.toRadians(-26.09F), 0, 0.0F, 60); progressRotation(main_head, turtle.lurkingProgress, (float) Math.toRadians(46.96F), 0.0F, 0.0F, 60); progressRotation(hand_left, turtle.lurkingProgress, 0, (float) Math.toRadians(-33.91F), (float) Math.toRadians(41.74F), 60); progressRotation(hand_right, turtle.lurkingProgress, 0, (float) Math.toRadians(33.91F), (float) Math.toRadians(-41.74F), 60); progressRotation(leg_left, turtle.lurkingProgress, 0, (float) Math.toRadians(-62.61F), (float) Math.toRadians(60F), 60); progressRotation(leg_right, turtle.lurkingProgress, 0, (float) Math.toRadians(62.61F), (float) Math.toRadians(-60F), 60); }*/ if (turtle.isInWater() && !turtle.isOnGround()) { float pitch = Mth.clamp(turtle.getXRot(), -45F, 45.0F) - 10; this.setRotateAngle(main_body, (float) (pitch * Math.PI / 180F), 0, 0); //this.setRotateAngle(main_body, (float) (turtle.getDeltaMovement().getY() * -30 * Math.PI / 180F), 0, 0); } this.main_body.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F), (float) (1F + Math.sin(ageInTicks / 16) * 0.06F)); this.body_shell.setScale((float) (1F + Math.sin(ageInTicks / 20) * 0.03F), (float) (1F + Math.sin(ageInTicks / 16) * 0.03F), (float) (1F + Math.sin(ageInTicks / 16) * 0.03F)); walk(neck, 0.4F, 0.3F, false, 2.8f, 0.1F, ageInTicks / 16, 0.1F); this.setRotateAngle(neck, neck.rotateAngleX, turtle.head_movement.getA(), 0.0F); this.setRotateAngle(main_head, main_head.rotateAngleX, turtle.head_movement.getB(), 0.0F); swing(hand_left, globalSpeed, globalDegree * 1.4f, false, 0, 0.8f, limbSwing / 2, limbSwingAmount); swing(leg_left, globalSpeed, globalDegree * 1.2f, false, 0.8F, 0.1f, limbSwing / 2, limbSwingAmount); swing(hand_right, globalSpeed, globalDegree * 1.4f, false, 1.6F, 0.8f, limbSwing / 2, limbSwingAmount); swing(leg_right, globalSpeed, globalDegree * 1.2f, false, 2.4F, 0.1f, limbSwing / 2, limbSwingAmount); if (turtle.isInWater()) { if (!turtle.isOnGround()) swing(hand_left, globalSpeed, globalDegree * 0.8f, false, 0, 0.1f, limbSwing / 2, limbSwingAmount); flap(hand_left, globalSpeed, globalDegree * 1.4f, false, 0, 0.1f, limbSwing / 2, limbSwingAmount); swing(hand_left, globalSpeed, globalDegree * 1.4f, false, 0, 0.1f, limbSwing / 2, limbSwingAmount); flap(leg_left, globalSpeed, globalDegree * 1.2f, false, 0.8F, 0.1f, limbSwing / 2, limbSwingAmount); swing(leg_left, globalSpeed, globalDegree * 1.2f, false, 0.8F, 0.1f, limbSwing / 2, limbSwingAmount); flap(hand_right, globalSpeed, globalDegree * 1.4f, false, 1.6F, 0.1f, limbSwing / 2, limbSwingAmount); swing(hand_right, globalSpeed, globalDegree * 1.4f, false, 1.6F, 0.1f, limbSwing / 2, limbSwingAmount); flap(leg_right, globalSpeed, globalDegree * 1.2f, false, 2.4F, 0.1f, limbSwing / 2, limbSwingAmount); swing(leg_right, globalSpeed, globalDegree * 1.2f, false, 2.4F, 0.1f, limbSwing / 2, limbSwingAmount); float f = netHeadYaw * 0.33F; float f1 = Mth.sin(f); float f3 = 0.13F * f1; this.main_body.rotateAngleX = Mth.lerp(0.1F, this.main_body.rotateAngleX, headPitch * ((float)Math.PI / 180F) + f3); flap(main_body, globalSpeed / 2, globalDegree * 1.2f, false, 0, 0.1f, limbSwing / 2, limbSwingAmount); swing(main_body, globalSpeed / 2, globalDegree * 1.2f, false, 0.8F, 0.1f, limbSwing / 3, limbSwingAmount); } } }
9,044
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelHippo.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelHippo.java
package untamedwilds.client.model; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.github.alexthe666.citadel.client.model.AdvancedEntityModel; import com.github.alexthe666.citadel.client.model.AdvancedModelBox; import com.github.alexthe666.citadel.client.model.ModelAnimator; import com.github.alexthe666.citadel.client.model.basic.BasicModelPart; import com.google.common.collect.ImmutableList; import net.minecraft.util.Mth; import untamedwilds.entity.mammal.EntityHippo; public class ModelHippo extends AdvancedEntityModel<EntityHippo> { public AdvancedModelBox body_main; public AdvancedModelBox head_neck; public AdvancedModelBox arm_right; public AdvancedModelBox arm_left; public AdvancedModelBox leg_right; public AdvancedModelBox leg_left; public AdvancedModelBox head_face; public AdvancedModelBox head_jaw; public AdvancedModelBox face_ear_right; public AdvancedModelBox head_jaw_1; public AdvancedModelBox face_ear_left; public AdvancedModelBox head_jaw_2; public AdvancedModelBox tooth_r; public AdvancedModelBox tooth_l; public AdvancedModelBox eye_right; public AdvancedModelBox eye_left; public AdvancedModelBox arm_right_2; public AdvancedModelBox arm_left_2; public AdvancedModelBox leg_right_2; public AdvancedModelBox leg_left_2; private final ModelAnimator animator; public ModelHippo() { this.texWidth = 128; this.texHeight = 64; this.body_main = new AdvancedModelBox(this, 0, 0); this.body_main.setRotationPoint(0.0F, 12.5F, 0.0F); this.body_main.addBox(-6.0F, -6.0F, -12.0F, 12, 12, 24, 0.0F); this.head_neck = new AdvancedModelBox(this, 48, 0); this.head_neck.setRotationPoint(0.0F, -0.6F, -10.0F); this.head_neck.addBox(-5.0F, -5.0F, -6.0F, 10, 10, 6, 0.0F); this.setRotateAngle(head_neck, 0.045553093477052F, 0.0F, 0.0F); this.head_face = new AdvancedModelBox(this, 0, 36); this.head_face.setRotationPoint(0.0F, -2.0F, -5.0F); this.head_face.addBox(-4.5F, -3.5F, -6.0F, 9, 9, 8, 0.0F); this.setRotateAngle(head_face, 0.2F, 0.0F, 0.0F); this.eye_left = new AdvancedModelBox(this, 0, 37); this.eye_left.setRotationPoint(4.51F, -2.0F, -4.0F); this.eye_left.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.eye_right = new AdvancedModelBox(this, 0, 37); this.eye_right.setRotationPoint(-4.51F, -2.0F, -4.0F); this.eye_right.addBox(0.0F, -0.5F, -1.0F, 0, 1, 2, 0.0F); this.face_ear_left = new AdvancedModelBox(this, 0, 36); this.face_ear_left.mirror = true; this.face_ear_left.setRotationPoint(3.0F, -3.0F, -3.0F); this.face_ear_left.addBox(0.0F, -2.0F, 0.0F, 2, 2, 1, 0.0F); this.setRotateAngle(face_ear_left, 0.136659280431156F, 0.091106186954104F, 0.36425021489121656F); this.face_ear_right = new AdvancedModelBox(this, 0, 36); this.face_ear_right.setRotationPoint(-3.0F, -3.0F, -3.0F); this.face_ear_right.addBox(-2.0F, -2.0F, 0.0F, 2, 2, 1, 0.0F); this.setRotateAngle(face_ear_right, 0.136659280431156F, -0.091106186954104F, -0.36425021489121656F); this.head_jaw = new AdvancedModelBox(this, 36, 36); this.head_jaw.setRotationPoint(0.0F, 0.0F, -6.0F); this.head_jaw.addBox(-4.0F, -3.0F, -7.0F, 8, 5, 8, 0.0F); this.head_jaw_2 = new AdvancedModelBox(this, 36, 49); this.head_jaw_2.setRotationPoint(0.0F, 2.0F, 0.0F); this.head_jaw_2.addBox(-4.0F, 0.0F, -7.0F, 8, 1, 8, 0.0F); this.head_jaw_1 = new AdvancedModelBox(this, 0, 53); this.head_jaw_1.setRotationPoint(0.0F, 1.5F, -4.5F); this.head_jaw_1.addBox(-4.0F, 0.0F, -8.0F, 8, 3, 8, 0.0F); this.tooth_r = new AdvancedModelBox(this, 0, 53); this.tooth_r.setRotationPoint(-2.5F, 0.0F, -5.5F); this.tooth_r.addBox(-0.5F, -2.0F, -1.0F, 1, 2, 2, 0.0F); this.tooth_l = new AdvancedModelBox(this, 0, 53); this.tooth_l.setRotationPoint(2.5F, 0.0F, -5.5F); this.tooth_l.addBox(-0.5F, -2.0F, -1.0F, 1, 2, 2, 0.0F); this.arm_right = new AdvancedModelBox(this, 0, 0); this.arm_right.setRotationPoint(-3.49F, 3.5F, -8.5F); this.arm_right.addBox(-2.5F, 0.0F, -2.5F, 5, 5, 5, 0.0F); this.arm_right_2 = new AdvancedModelBox(this, 0, 12); this.arm_right_2.setRotationPoint(0.0F, 3.0F, 0.0F); this.arm_right_2.addBox(-2.51F, 0.0F, -2.51F, 5, 5, 5, 0.0F); this.arm_left = new AdvancedModelBox(this, 0, 0); this.arm_left.mirror = true; this.arm_left.setRotationPoint(3.49F, 3.5F, -8.5F); this.arm_left.addBox(-2.5F, 0.0F, -2.5F, 5, 5, 5, 0.0F); this.arm_left_2 = new AdvancedModelBox(this, 0, 12); this.arm_left_2.mirror = true; this.arm_left_2.setRotationPoint(0.0F, 3.0F, 0.0F); this.arm_left_2.addBox(-2.51F, 0.0F, -2.51F, 5, 5, 5, 0.0F); this.leg_right = new AdvancedModelBox(this, 0, 0); this.leg_right.setRotationPoint(-3.49F, 3.5F, 8.5F); this.leg_right.addBox(-2.5F, 0.0F, -2.5F, 5, 5, 5, 0.0F); this.leg_right_2 = new AdvancedModelBox(this, 0, 12); this.leg_right_2.setRotationPoint(0.0F, 3.0F, 0.0F); this.leg_right_2.addBox(-2.51F, 0.0F, -2.51F, 5, 5, 5, 0.0F); this.leg_left = new AdvancedModelBox(this, 0, 0); this.leg_left.setRotationPoint(3.49F, 3.5F, 8.5F); this.leg_left.addBox(-2.5F, 0.0F, -2.5F, 5, 5, 5, 0.0F); this.leg_left_2 = new AdvancedModelBox(this, 0, 12); this.leg_left_2.setRotationPoint(0.0F, 3.0F, 0.0F); this.leg_left_2.addBox(-2.51F, 0.0F, -2.51F, 5, 5, 5, 0.0F); this.body_main.addChild(this.arm_left); this.head_jaw_1.addChild(this.tooth_r); this.head_face.addChild(this.face_ear_left); this.leg_left.addChild(this.leg_left_2); this.arm_left.addChild(this.arm_left_2); this.head_neck.addChild(this.head_face); this.head_jaw.addChild(this.head_jaw_2); this.head_face.addChild(this.head_jaw); this.head_face.addChild(this.head_jaw_1); this.body_main.addChild(this.head_neck); this.body_main.addChild(this.leg_right); this.body_main.addChild(this.leg_left); this.head_jaw_1.addChild(this.tooth_l); this.arm_right.addChild(this.arm_right_2); this.body_main.addChild(this.arm_right); this.head_face.addChild(this.face_ear_right); this.leg_right.addChild(this.leg_right_2); this.head_face.addChild(this.eye_left); this.head_face.addChild(this.eye_right); animator = ModelAnimator.create(); updateDefaultPose(); } @Override public Iterable<BasicModelPart> parts() { return ImmutableList.of(this.body_main); } @Override public Iterable<AdvancedModelBox> getAllParts() { return ImmutableList.of( body_main, head_neck, arm_right, arm_left, leg_right, leg_left, head_face, head_jaw, face_ear_right, head_jaw_1, face_ear_left, head_jaw_2, tooth_r, tooth_l, eye_right, eye_left, arm_right_2, arm_left_2, leg_right_2, leg_left_2 ); } private void animate(IAnimatedEntity entityIn) { this.resetToDefaultPose(); EntityHippo bear = (EntityHippo) entityIn; animator.update(bear); animator.setAnimation(EntityHippo.EAT); animator.startKeyframe(12); this.rotate(animator, head_neck, 18.26F, 0, 0); this.rotate(animator, head_face, 26.09F, 0, 5.22F); animator.endKeyframe(); animator.startKeyframe(12); this.rotate(animator, head_neck, 18.26F, 0, 0); this.rotate(animator, head_face, 20.87F, 5.22F, 0); this.rotate(animator, head_jaw, -10.43F, 0, 0); this.rotate(animator, head_jaw_1, 10.43F, 0, 0); animator.endKeyframe(); animator.startKeyframe(12); this.rotate(animator, head_neck, 18.26F, 0, 0); this.rotate(animator, head_face, 26.09F, -5.22F, 0); animator.endKeyframe(); animator.resetKeyframe(12); animator.setAnimation(EntityHippo.IDLE_YAWN); animator.startKeyframe(8); this.rotate(animator, head_neck, -28.70F, 0, 0); this.rotate(animator, head_face, -10.43F, 0, 0); animator.move(head_jaw, 0, -1F, 0); this.rotate(animator, head_jaw, -28.70F, 0, 0); this.rotate(animator, head_jaw_1, 54.78F, 0, 0); animator.endKeyframe(); animator.startKeyframe(10); this.rotate(animator, head_neck, -28.70F, 0, 0); this.rotate(animator, head_face, -10.43F, 0, 2.61F); animator.move(head_jaw, 0, -1F, 0); this.rotate(animator, head_jaw, -44.35F, 0, 0); this.rotate(animator, head_jaw_1, 62.61F, 0, 0); animator.endKeyframe(); animator.startKeyframe(10); this.rotate(animator, head_neck, -28.70F, 0, 0); this.rotate(animator, head_face, -10.43F, 0, -2.61F); animator.move(head_jaw, 0, -1F, 0); this.rotate(animator, head_jaw, -44.35F, 0, 0); this.rotate(animator, head_jaw_1, 62.61F, 0, 0); animator.endKeyframe(); animator.resetKeyframe(8); animator.setAnimation(EntityHippo.IDLE_LOOK); animator.startKeyframe(32); this.rotate(animator, head_neck, -20.87F, 5.22F, 0); this.rotate(animator, head_face, 15.65F, 31.30F, 7.83F); animator.endKeyframe(); animator.startKeyframe(64); this.rotate(animator, head_neck, -20.87F, -7.83F, 0); this.rotate(animator, head_face, 13.04F, -7.83F, -5.22F); animator.endKeyframe(); animator.resetKeyframe(32); animator.setAnimation(EntityHippo.ATTACK); animator.startKeyframe(6); this.rotate(animator, head_neck, -13.05F, 0, 0); this.rotate(animator, head_face, 13.05F, -10.43F, -7.83F); animator.move(head_jaw, 0, -1F, 0); this.rotate(animator, head_jaw, -28.70F, 0, 0); this.rotate(animator, head_jaw_1, 36F, 0, 0); animator.endKeyframe(); animator.startKeyframe(6); this.rotate(animator, head_neck, -13.05F, 7.83F, 0); this.rotate(animator, head_face, -13.04F, 23.48F, -26.09F); animator.move(head_jaw, 0, -1F, 0); this.rotate(animator, head_jaw, -28.70F, 0, 0); this.rotate(animator, head_jaw_1, 36F, 0, 0); animator.endKeyframe(); animator.startKeyframe(6); this.rotate(animator, head_neck, -13.05F, -10.43F, 0); this.rotate(animator, head_face, -13.04F, -20.87F, -2.61F); animator.move(head_jaw, 0, -1F, 0); this.rotate(animator, head_jaw, -28.70F, 0, 0); this.rotate(animator, head_jaw_1, 36F, 0, 0); animator.endKeyframe(); animator.resetKeyframe(6); animator.setAnimation(EntityHippo.IDLE_TALK); animator.startKeyframe(10); this.rotate(animator, head_jaw, 26.09F, 0, 0); this.rotate(animator, head_face, -26.09F, 0, 0); animator.endKeyframe(); animator.resetKeyframe(10); } public void setupAnim(EntityHippo hippo, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { animate(hippo); //limbSwing = ageInTicks / 3; //limbSwingAmount = 0.5f; float globalSpeed = 1.5f; float globalDegree = 1f; float f = limbSwing / 2; if (limbSwingAmount > 0.4F) { limbSwingAmount = 0.4F; } if (!hippo.shouldRenderEyes()) { this.eye_right.setRotationPoint(-2F, -2.0F, -4.0F); this.eye_left.setRotationPoint(2F, -2.0F, -4.0F); } if (hippo.isInWater() && !hippo.isOnGround()) { float pitch = Mth.clamp(hippo.getXRot() - 10, -25F, 25.0F); this.setRotateAngle(body_main, (float) (pitch * Math.PI / 180F), 0, 0); } if (!hippo.isSleeping()) { this.faceTarget(netHeadYaw, headPitch, 3, head_neck); this.faceTarget(netHeadYaw, headPitch, 3, head_face); } this.head_jaw_1.setScaleX(0.9F); this.body_main.setScale((float) (1.0F + Math.sin(ageInTicks / 20) * 0.06F), (float) (1.0F + Math.sin(ageInTicks / 16) * 0.06F), 1.0F); bob(body_main, 0.4F * globalSpeed, 0.1F, false, ageInTicks / 20, 2); bob(arm_right, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(arm_left, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_right, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); bob(leg_left, 0.4F * globalSpeed, 0.1F, false, -ageInTicks / 20, 2); walk(head_face, 0.4f * globalSpeed, 0.03f, false, 2.8F, 0.06F, ageInTicks / 20, 2); if (hippo.angryProgress != 0) { this.progressRotation(head_jaw_1, hippo.angryProgress, 0.36425021489121656F, 0.0F, 0.0F, 40); } if (hippo.sitProgress != 0) { if (hippo.isSitting()) { this.progressPosition(body_main, hippo.sitProgress, 0.0F, 18.5F, 0.0F, 40); this.progressRotation(body_main, hippo.sitProgress, 0.0F, 0.091106186954104F, 0.0F, 40); this.progressPosition(head_neck, hippo.sitProgress, 0, 0, -10.0F, 40); this.progressRotation(head_neck, hippo.sitProgress, 0.18203784098300857F, 0.0F, 0.0F, 40); this.progressPosition(head_face, hippo.sitProgress, 0.0F, -1.0F, -5.0F, 40); this.progressRotation(head_face, hippo.sitProgress, 00.0F, -0.27314402793711257F, 0.045553093477052F, 40); this.progressRotation(arm_right, hippo.sitProgress, -1.5025539530419183F, 0.27314402793711257F, 0.0F, 40); this.progressRotation(arm_left, hippo.sitProgress, -1.5025539530419183F, -0.27314402793711257F, 0.0F, 40); this.progressRotation(leg_right, hippo.sitProgress, -1.5481070465189704F, 2.5497515042385164F, 0.0F, 40); this.progressRotation(leg_left, hippo.sitProgress, -1.5481070465189704F, -2.5497515042385164F, 0.0F, 40); } if (hippo.isSleeping()) { this.progressPosition(body_main, hippo.sitProgress, 0.0F, 18.5F, 0.0F, 40); this.progressRotation(body_main, hippo.sitProgress, 0.0F, 0.091106186954104F, 0.0F, 40); this.progressPosition(head_neck, hippo.sitProgress, 0, 0, -10.0F, 40); this.progressRotation(head_neck, hippo.sitProgress, 0.18203784098300857F, 0.0F, 0.0F, 40); this.progressPosition(head_face, hippo.sitProgress, 0.0F, -1.0F, -5.0F, 40); this.progressRotation(head_face, hippo.sitProgress, 0.0F, -0.27314402793711257F, 0.045553093477052F, 40); this.progressRotation(arm_right, hippo.sitProgress, -1.5025539530419183F, 0.27314402793711257F, 0.0F, 40); this.progressRotation(arm_left, hippo.sitProgress, -1.5025539530419183F, -0.27314402793711257F, 0.0F, 40); this.progressRotation(leg_right, hippo.sitProgress, -1.5481070465189704F, 2.5497515042385164F, 0.0F, 40); this.progressRotation(leg_left, hippo.sitProgress, -1.5481070465189704F, -2.5497515042385164F, 0.0F, 40); } } // Controls the walking animation if (hippo.canMove()) { bob(body_main, 0.6f * globalSpeed, 0.6f * globalDegree, true, f, limbSwingAmount); walk(head_neck, 0.6f * globalSpeed, 0.2f * globalDegree, false, 0, 0, f, limbSwingAmount); walk(head_face, 0.6f * globalSpeed, 0.15f * globalDegree, true, 0, 0, f, limbSwingAmount); walk(arm_right, -0.6f * globalSpeed, 1.4f * globalDegree, true, 0F, 1.4f, f, limbSwingAmount); walk(arm_right_2, -0.6f * globalSpeed, 1.4f * globalDegree, false, -1F, 1.4f, f, limbSwingAmount * 1.2f); walk(arm_left, -0.6f * globalSpeed, 1.4f * globalDegree, true, 2F, 1.4f, f, limbSwingAmount); walk(arm_left_2, -0.6f * globalSpeed, 1.4f * globalDegree, false, 1F, 1.4f, f, limbSwingAmount * 1.2f); walk(leg_right, 0.6f * globalSpeed, 1.4f * globalDegree, false, 2.8F, 0, f, limbSwingAmount); walk(leg_right_2, 0.6f * globalSpeed, 1.4f * globalDegree, true, 1.8F, 0, f, limbSwingAmount); walk(leg_left, 0.6f * globalSpeed, 1.4f * globalDegree, false, 0.8F, 0, f, limbSwingAmount); walk(leg_left_2, 0.6f * globalSpeed, 1.4f * globalDegree, true, -0.2F, 0, f, limbSwingAmount); } } }
16,883
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModelProjectileSpit.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/client/model/ModelProjectileSpit.java
package untamedwilds.client.model; import net.minecraft.client.model.HierarchicalModel; import net.minecraft.client.model.geom.ModelPart; import net.minecraft.client.model.geom.PartPose; import net.minecraft.client.model.geom.builders.CubeListBuilder; import net.minecraft.client.model.geom.builders.LayerDefinition; import net.minecraft.client.model.geom.builders.MeshDefinition; import net.minecraft.client.model.geom.builders.PartDefinition; import net.minecraft.world.entity.Entity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class ModelProjectileSpit<T extends Entity> extends HierarchicalModel<T> { private static final String MAIN = "main"; private final ModelPart root; public ModelProjectileSpit(ModelPart p_170730_) { this.root = p_170730_; } public static LayerDefinition createBodyLayer() { MeshDefinition meshdefinition = new MeshDefinition(); PartDefinition partdefinition = meshdefinition.getRoot(); int i = 2; partdefinition.addOrReplaceChild("main", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, 0.0F, 0.0F, 2.0F, 2.0F, 2.0F).addBox(0.0F, -4.0F, 0.0F, 2.0F, 2.0F, 2.0F).addBox(0.0F, 0.0F, -4.0F, 2.0F, 2.0F, 2.0F).addBox(0.0F, 0.0F, 0.0F, 2.0F, 2.0F, 2.0F).addBox(2.0F, 0.0F, 0.0F, 2.0F, 2.0F, 2.0F).addBox(0.0F, 2.0F, 0.0F, 2.0F, 2.0F, 2.0F).addBox(0.0F, 0.0F, 2.0F, 2.0F, 2.0F, 2.0F), PartPose.ZERO); return LayerDefinition.create(meshdefinition, 64, 32); } public void setupAnim(T p_103090_, float p_103091_, float p_103092_, float p_103093_, float p_103094_, float p_103095_) { } public ModelPart root() { return this.root; } }
1,738
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
UntamedInstance.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/network/UntamedInstance.java
package untamedwilds.network; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.network.NetworkDirection; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import untamedwilds.UntamedWilds; public class UntamedInstance { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel( new ResourceLocation(UntamedWilds.MOD_ID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); private static int ID = 0; public static void registerMessages() { UntamedWilds.LOGGER.info("Registering Packets!"); INSTANCE.messageBuilder(SyncTextureData.class, ID++) .encoder(SyncTextureData::toBytes) .decoder(SyncTextureData::new) .consumer(SyncTextureData::handle) .add(); } public static void sendToClient(Object packet, ServerPlayer player) { INSTANCE.sendTo(packet, player.connection.connection, NetworkDirection.PLAY_TO_CLIENT); } public static void sendToServer(Object packet) { INSTANCE.sendToServer(packet); } }
1,326
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
SyncTextureData.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/network/SyncTextureData.java
package untamedwilds.network; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.entity.EntityType; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkEvent; import net.minecraftforge.registries.ForgeRegistries; import untamedwilds.UntamedWilds; import untamedwilds.entity.ComplexMob; import untamedwilds.util.EntityDataHolderClient; import untamedwilds.util.EntityUtils; import java.util.HashMap; import java.util.function.Supplier; public class SyncTextureData { private final ResourceLocation entityName; private final String speciesName; private final Integer skinsData; private final Integer id; public SyncTextureData(FriendlyByteBuf buf) { entityName = buf.readResourceLocation(); speciesName = buf.readUtf(); skinsData = buf.readInt(); id = buf.readInt(); } public SyncTextureData(ResourceLocation str, String species_name, Integer skins, Integer id) { this.entityName = str; this.speciesName = species_name; this.skinsData = skins; this.id = id; } public void toBytes(FriendlyByteBuf buf) { buf.writeResourceLocation(entityName); buf.writeUtf(speciesName); buf.writeInt(skinsData); buf.writeInt(id); } public boolean handle(Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> { if (UntamedWilds.DEBUG) { UntamedWilds.LOGGER.info("Handling texture data for entity: " + entityName + " with species: " + speciesName); } EntityType<?> type = ForgeRegistries.ENTITIES.getValue(entityName); if (!ComplexMob.CLIENT_DATA_HASH.containsKey(type)) { ComplexMob.CLIENT_DATA_HASH.put(type, new EntityDataHolderClient(new HashMap<>(), new HashMap<>())); } EntityUtils.buildSkinArrays(entityName.getPath(), speciesName, skinsData, id, ComplexMob.TEXTURES_COMMON, ComplexMob.TEXTURES_RARE); ComplexMob.CLIENT_DATA_HASH.get(type).addSpeciesName(id, speciesName); }); return true; } }
2,142
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModTags.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/init/ModTags.java
package untamedwilds.init; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.tags.TagKey; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.block.Block; import untamedwilds.UntamedWilds; public class ModTags { public static class EntityTags { // The CAGE_BLACKLIST is provided for mod packs and/or data pack makers, nothing is there by default (players are hard-blacklisted since they will crash the game) public static final TagKey<EntityType<?>> CAGE_BLACKLIST = TagKey.create(Registry.ENTITY_TYPE_REGISTRY, new ResourceLocation(UntamedWilds.MOD_ID, "cage_trap_blacklist")); } public static class ModBlockTags { public static final TagKey<Block> REEDS_PLANTABLE_ON = BlockTags.create(new ResourceLocation(UntamedWilds.MOD_ID, "reeds_plantable_on")); public static final TagKey<Block> ALOE_PLANTABLE_ON = BlockTags.create(new ResourceLocation(UntamedWilds.MOD_ID, "aloe_plantable_on")); public static final TagKey<Block> GRAZEABLE_BLOCKS = BlockTags.create(new ResourceLocation(UntamedWilds.MOD_ID, "grazeable_blocks")); public static final TagKey<Block> GRAZEABLE_ALGAE = BlockTags.create(new ResourceLocation(UntamedWilds.MOD_ID, "grazeable_algae")); public static final TagKey<Block> VALID_REPTILE_NEST = BlockTags.create(new ResourceLocation(UntamedWilds.MOD_ID, "valid_reptile_nest")); } }
1,493
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModSounds.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/init/ModSounds.java
package untamedwilds.init; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import untamedwilds.UntamedWilds; @SuppressWarnings("unused") @Mod.EventBusSubscriber(modid = UntamedWilds.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModSounds { public static final DeferredRegister<SoundEvent> SOUNDS = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, UntamedWilds.MOD_ID); public static final SoundEvent ENTITY_ATTACK_BITE = registerSound("entity.generic.bite"); public static final SoundEvent ENTITY_HIPPO_AMBIENT = registerSound("entity.hippo.ambient"); public static final SoundEvent ENTITY_BISON_AMBIENT = registerSound("entity.bison.ambient"); public static final SoundEvent ENTITY_BEAR_AMBIENT = registerSound("entity.bear.ambient"); public static final SoundEvent ENTITY_BEAR_WARNING = registerSound("entity.bear.warning"); public static final SoundEvent ENTITY_BEAR_HURT = registerSound("entity.bear.hurt"); public static final SoundEvent ENTITY_BEAR_DEATH = registerSound("entity.bear.death"); public static final SoundEvent ENTITY_BEAR_BABY_AMBIENT = registerSound("entity.bear.baby.ambient"); public static final SoundEvent ENTITY_BEAR_BABY_CRY = registerSound("entity.bear.baby.cry"); public static final SoundEvent ENTITY_BIG_CAT_AMBIENT = registerSound("entity.big_cat.ambient"); public static final SoundEvent ENTITY_BIG_CAT_HURT = registerSound("entity.big_cat.hurt"); public static final SoundEvent ENTITY_BIG_CAT_DEATH = registerSound("entity.big_cat.death"); public static final SoundEvent ENTITY_AARDVARK_AMBIENT = registerSound("entity.aardvark.ambient"); public static final SoundEvent ENTITY_AARDVARK_HURT = registerSound("entity.aardvark.hurt"); public static final SoundEvent ENTITY_AARDVARK_DEATH = registerSound("entity.aardvark.death"); public static final SoundEvent ENTITY_HYENA_LAUGHING = registerSound("entity.hyena.laugh"); public static final SoundEvent ENTITY_HYENA_GROWL = registerSound("entity.hyena.growl"); public static final SoundEvent ENTITY_HYENA_AMBIENT = registerSound("entity.hyena.ambient"); public static final SoundEvent ENTITY_HYENA_HURT = registerSound("entity.hyena.hurt"); public static final SoundEvent ENTITY_HYENA_DEATH = registerSound("entity.hyena.death"); public static final SoundEvent ENTITY_BOAR_SQUEAL = registerSound("entity.boar.squeal"); public static final SoundEvent ENTITY_BOAR_AMBIENT = registerSound("entity.boar.ambient"); public static final SoundEvent ENTITY_BOAR_HURT = registerSound("entity.boar.hurt"); public static final SoundEvent ENTITY_BOAR_DEATH = registerSound("entity.boar.death"); public static final SoundEvent ENTITY_CAMEL_SPIT = registerSound("entity.camel.spit"); public static final SoundEvent ENTITY_CAMEL_AMBIENT = registerSound("entity.camel.ambient"); public static final SoundEvent ENTITY_CAMEL_HURT = registerSound("entity.camel.hurt"); public static final SoundEvent ENTITY_CAMEL_DEATH = registerSound("entity.camel.death"); public static final SoundEvent ENTITY_SPITTER_SPIT = registerSound("entity.spitter.spit"); public static final SoundEvent ENTITY_SPITTER_AMBIENT = registerSound("entity.spitter.ambient"); public static final SoundEvent ENTITY_SPITTER_HURT = registerSound("entity.spitter.hurt"); public static final SoundEvent ENTITY_SPITTER_DEATH = registerSound("entity.spitter.death"); public static final SoundEvent ENTITY_OPOSSUM_HISS = registerSound("entity.opossum.hiss"); public static final SoundEvent ENTITY_OPOSSUM_AMBIENT = registerSound("entity.opossum.ambient"); public static final SoundEvent ENTITY_OPOSSUM_HURT = registerSound("entity.opossum.hurt"); public static final SoundEvent ENTITY_OPOSSUM_DEATH = registerSound("entity.opossum.death"); public static final SoundEvent ENTITY_TARANTULA_AMBIENT = registerSound("entity.tarantula.ambient"); public static final SoundEvent ENTITY_SNAKE_HISS = registerSound("entity.snake.warning"); public static final SoundEvent ENTITY_SNAKE_RATTLE = registerSound("entity.snake.rattle"); private static SoundEvent registerSound(String soundName) { ResourceLocation location = new ResourceLocation(UntamedWilds.MOD_ID, soundName); SoundEvent event = new SoundEvent(location); ModSounds.SOUNDS.register(soundName, () -> event); return event; } }
4,628
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModVillagerTrades.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/init/ModVillagerTrades.java
package untamedwilds.init; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerTrades; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.trading.MerchantOffer; import net.minecraftforge.event.village.VillagerTradesEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import untamedwilds.UntamedWilds; import java.util.Random; @Mod.EventBusSubscriber(modid = UntamedWilds.MOD_ID) public class ModVillagerTrades { @SubscribeEvent public static void onVillagerTradesEvent(VillagerTradesEvent event) { if (event.getType() == VillagerProfession.FISHERMAN) { event.getTrades().get(3).add(new setupOffer(Items.EMERALD, 1, ModItems.MATERIAL_PEARL.get(), 1, 6, 8, 0.2F)); event.getTrades().get(3).add(new setupOffer(ModItems.MATERIAL_PEARL.get(), 2, Items.EMERALD, 1, 6, 8, 0.2F)); event.getTrades().get(4).add(new setupOffer(ModItems.RARE_GIANT_PEARL.get(), 1, Items.EMERALD, 6, 3, 5, 0.2F)); } if (event.getType() == VillagerProfession.BUTCHER) { event.getTrades().get(3).add(new setupOffer(ModItems.MATERIAL_BLUBBER.get(), 6, Items.EMERALD, 1, 12, 5, 0.05F)); event.getTrades().get(3).add(new setupOffer(Items.EMERALD, 1, ModItems.MATERIAL_FAT.get(), 4, 12, 5, 0.05F)); } } public static class setupOffer implements VillagerTrades.ItemListing { private final Item itemstackIn; private final int stackSizeIn; private final Item itemstackOut; private final int stackSizeOut; private final int maxUses; private final int givenExp; private final float priceMultiplier; setupOffer(Item stackOut, int sizeOut, Item stackIn, int sizeIn, int maxUses, int givenExp, float priceMultiplier) { this.itemstackIn = stackIn; this.stackSizeIn = sizeIn; this.itemstackOut = stackOut; this.stackSizeOut = sizeOut; this.maxUses = maxUses; this.givenExp = givenExp; this.priceMultiplier = priceMultiplier; } public MerchantOffer getOffer(Entity entityIn, Random rand) { return new MerchantOffer(new ItemStack(this.itemstackOut, this.stackSizeOut), new ItemStack(this.itemstackIn, this.stackSizeIn), this.maxUses, this.givenExp, this.priceMultiplier); } } }
2,581
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModBlock.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/init/ModBlock.java
package untamedwilds.init; import com.google.common.collect.Lists; import com.mojang.datafixers.util.Pair; import net.minecraft.client.Minecraft; import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.block.BlockColors; import net.minecraft.client.renderer.BiomeColors; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.GrassColor; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import untamedwilds.UntamedWilds; import untamedwilds.block.*; import untamedwilds.block.blockentity.CageBlockEntity; import untamedwilds.block.blockentity.CritterBurrowBlockEntity; import untamedwilds.block.blockentity.EggBlockEntity; import untamedwilds.block.blockentity.ReptileNestBlockEntity; import untamedwilds.util.ModCreativeModeTab; import javax.annotation.Nullable; import java.util.List; import java.util.Objects; import java.util.function.Supplier; @SuppressWarnings("unused") @Mod.EventBusSubscriber(modid = UntamedWilds.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModBlock { public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, UntamedWilds.MOD_ID); public static final DeferredRegister<BlockEntityType<?>> TILE_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, UntamedWilds.MOD_ID); private final static List<Pair<RegistryObject<Block>, String>> RENDER_TYPE_DATA = Lists.newArrayList(); // Carpets public static RegistryObject<Block> CARPET_STRAW = createBlock("carpet_straw", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.SAND).destroyTime(0.1F).sound(SoundType.CROP)), CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CARPET_BEAR_ASHEN = createBlock("carpet_bear_ashen", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.COLOR_GRAY).destroyTime(0.1F).sound(SoundType.WOOL)), CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CARPET_BEAR_BLACK = createBlock("carpet_bear_black", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.COLOR_BLACK).destroyTime(0.1F).sound(SoundType.WOOL)), CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CARPET_BEAR_BROWN = createBlock("carpet_bear_brown", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.COLOR_BROWN).destroyTime(0.1F).sound( SoundType.WOOL)), CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CARPET_BEAR_WHITE = createBlock("carpet_bear_white", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.SNOW).destroyTime(0.1F).sound( SoundType.WOOL)), CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CARPET_BIGCAT_JAGUAR = createBlock("carpet_bigcat_jaguar", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.GOLD).destroyTime(0.1F).sound( SoundType.WOOL)), CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CARPET_BIGCAT_LEOPARD = createBlock("carpet_bigcat_leopard", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.GOLD).destroyTime(0.1F).sound( SoundType.WOOL)), CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CARPET_BIGCAT_LION = createBlock("carpet_bigcat_lion", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.COLOR_BROWN).destroyTime(0.1F).sound( SoundType.WOOL)), CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CARPET_BIGCAT_PANTHER = createBlock("carpet_bigcat_panther", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.SNOW).destroyTime(0.1F).sound( SoundType.WOOL)), CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CARPET_BIGCAT_PUMA = createBlock("carpet_bigcat_puma", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.COLOR_GRAY).destroyTime(0.1F).sound( SoundType.WOOL)), CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CARPET_BIGCAT_SNOW = createBlock("carpet_bigcat_snow_leopard", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.COLOR_BLACK).destroyTime(0.1F).sound( SoundType.WOOL)), CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CARPET_BIGCAT_TIGER = createBlock("carpet_bigcat_tiger", () -> new CarpetBlock(Block.Properties.of(Material.CLOTH_DECORATION, MaterialColor.COLOR_BROWN).destroyTime(0.1F).sound( SoundType.WOOL)), CreativeModeTab.TAB_DECORATIONS); // Storage public static RegistryObject<Block> LARD_BLOCK = createBlock("block_lard", () -> new LardBlock(Block.Properties.of(Material.CLAY, MaterialColor.COLOR_YELLOW).destroyTime(0.1F).sound(SoundType.SLIME_BLOCK)), CreativeModeTab.TAB_BUILDING_BLOCKS); public static RegistryObject<Block> PEARL_BLOCK = createBlock("block_pearl", () -> new Block(Block.Properties.of(Material.STONE, MaterialColor.COLOR_CYAN).destroyTime(5.0F).sound(SoundType.STONE)), CreativeModeTab.TAB_BUILDING_BLOCKS); // Machines public static RegistryObject<Block> TRAP_CAGE = createBlock("trap_cage", () -> new CageBlock(Block.Properties.of(Material.WOOD, MaterialColor.WOOD).destroyTime(3.0F).sound(SoundType.WOOD)), CreativeModeTab.TAB_TRANSPORTATION); // Fauna public static RegistryObject<Block> ANEMONE_ROSE_BULB = createBlock("anemone_rose_bulb", () -> new AnemoneBlock(Block.Properties.of(Material.WATER_PLANT, MaterialColor.COLOR_RED).destroyTime(0.1F).sound(SoundType.SLIME_BLOCK)), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> ANEMONE_SAND = createBlock("anemone_sand", () -> new AnemoneBlock(Block.Properties.of(Material.WATER_PLANT, MaterialColor.COLOR_PINK).destroyTime(0.1F).sound(SoundType.SLIME_BLOCK)), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> ANEMONE_SEBAE = createBlock("anemone_sebae", () -> new AnemoneBlock(Block.Properties.of(Material.WATER_PLANT, MaterialColor.TERRACOTTA_WHITE).destroyTime(0.1F).sound(SoundType.SLIME_BLOCK)), "cutout", CreativeModeTab.TAB_DECORATIONS); // Flora - Reeds public static RegistryObject<Block> COMMON_REED = createBlock("flora_common_reed", () -> new ReedBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(0.1F).sound(SoundType.VINE).noCollission()), "cutout", CreativeModeTab.TAB_DECORATIONS, 100); // Flora - Bushes public static RegistryObject<Block> BUSH_TEMPERATE = createBlock("flora_bush_temperate", () -> new UndergrowthBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(1.0F).sound(SoundType.AZALEA_LEAVES).noCollission()), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> BUSH_CREOSOTE = createBlock("flora_bush_creosote", () -> new UndergrowthBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(1.0F).sound(SoundType.AZALEA_LEAVES).noCollission()), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> ELEPHANT_EAR = createBlock("flora_elephant_ear", () -> new UndergrowthBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(1.0F).sound(SoundType.WET_GRASS).noCollission(), BlockBehaviour.OffsetType.XYZ), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> HEMLOCK = createBlock("flora_hemlock", () -> new UndergrowthPoisonousBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(0.1F).sound(SoundType.GRASS).noCollission(), BlockBehaviour.OffsetType.XYZ), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> YARROW = createBlock("flora_yarrow", () -> new CustomGrassBlock(MobEffects.REGENERATION, 4, Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(0.0F).sound(SoundType.GRASS).noCollission()), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> JUNEGRASS = createBlock("flora_junegrass", () -> new CustomGrassBlock(MobEffects.UNLUCK, 4, Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(0.0F).sound(SoundType.GRASS).noCollission()), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> CANOLA = createBlock("flora_canola", () -> new CustomGrassBlock(MobEffects.DAMAGE_BOOST, 4, Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(0.0F).sound(SoundType.GRASS).noCollission()), "cutout", CreativeModeTab.TAB_DECORATIONS); // Flora - Multistage public static RegistryObject<Block> ZIMBABWE_ALOE = createItemlessBlock("flora_zimbabwe_aloe", () -> new TallPlantBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(1.0F).sound(SoundType.WOOD).dynamicShape()), "cutout"); public static RegistryObject<Block> PAMPAS_GRASS = createBlock("flora_pampas_grass", () -> new TallGrassBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(1.0F).sound(SoundType.GRASS).dynamicShape()), "cutout", CreativeModeTab.TAB_DECORATIONS); // Flora - Floating public static RegistryObject<Block> WATER_HYACINTH = createItemlessBlock("flora_water_hyacinth", () -> new FloatingPlantBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(0.0F).sound(SoundType.LILY_PAD).noCollission()), "cutout"); // Flora - Algae public static RegistryObject<Block> AMAZON_SWORD = createBlock("flora_amazon_sword", () -> new AlgaeBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(0).sound(SoundType.WET_GRASS).noCollission()), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> EELGRASS = createBlock("flora_eelgrass", () -> new AlgaeBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(0).sound(SoundType.WET_GRASS).noCollission()), "cutout", CreativeModeTab.TAB_DECORATIONS); // Flora - Flowers public static RegistryObject<Block> ORCHID_MAGENTA = createBlock("flora_orchid_magenta", () -> new EpyphitePlantBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_MAGENTA).destroyTime(0.0F).sound(SoundType.VINE)), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> ORCHID_PURPLE = createBlock("flora_orchid_purple", () -> new EpyphitePlantBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_PURPLE).destroyTime(0.0F).sound(SoundType.VINE)), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> ORCHID_PINK = createBlock("flora_orchid_pink", () -> new EpyphitePlantBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_PINK).destroyTime(0.0F).sound(SoundType.VINE)), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> ORCHID_RED = createBlock("flora_orchid_red", () -> new EpyphitePlantBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_RED).destroyTime(0.0F).sound(SoundType.VINE)), "cutout", CreativeModeTab.TAB_DECORATIONS); public static RegistryObject<Block> TITAN_ARUM = createItemlessBlock("flora_titan_arum", () -> new TitanArumBlock(Block.Properties.of(Material.PLANT, MaterialColor.COLOR_GREEN).destroyTime(2.0F).sound(SoundType.WET_GRASS).noCollission().dynamicShape()), "cutout"); // Nests public static RegistryObject<Block> NEST_REPTILE = createBlock("nest_reptile", () -> new NestReptileBlock(Block.Properties.of(Material.DIRT, MaterialColor.DIRT).destroyTime(1.0F).sound(SoundType.GRAVEL)), "translucent", ModCreativeModeTab.untamedwilds_items); // Eggs public static RegistryObject<Block> EGG_SPITTER = createBlock("egg_spitter", () -> new StrangeEggBlock(Block.Properties.of(Material.DIRT, MaterialColor.DIRT).destroyTime(1.0F).sound(SoundType.SLIME_BLOCK)), "cutout", ModCreativeModeTab.untamedwilds_items); // Technical Blocks public static RegistryObject<Block> BURROW = createBlock("block_burrow", () -> new CritterBurrowBlock(Block.Properties.of(Material.DIRT, MaterialColor.DIRT).destroyTime(1.0F).sound(SoundType.GRAVEL).noCollission()), "translucent", CreativeModeTab.TAB_DECORATIONS); // Block Entities public static final RegistryObject<BlockEntityType<CageBlockEntity>> TILE_ENTITY_CAGE = TILE_ENTITIES.register("trap_cage", () -> BlockEntityType.Builder.of(CageBlockEntity::new, ModBlock.TRAP_CAGE.get()).build(null)); public static final RegistryObject<BlockEntityType<CritterBurrowBlockEntity>> TILE_ENTITY_BURROW = TILE_ENTITIES.register("critter_burrow", () -> BlockEntityType.Builder.of(CritterBurrowBlockEntity::new, ModBlock.BURROW.get()).build(null)); public static final RegistryObject<BlockEntityType<ReptileNestBlockEntity>> TILE_ENTITY_NEST_REPTILE = TILE_ENTITIES.register("nest_reptile_block_entity", () -> BlockEntityType.Builder.of(ReptileNestBlockEntity::new, ModBlock.NEST_REPTILE.get()).build(null)); public static final RegistryObject<BlockEntityType<EggBlockEntity>> TILE_ENTITY_EGG = TILE_ENTITIES.register("strange_egg", () -> BlockEntityType.Builder.of(EggBlockEntity::new, ModBlock.EGG_SPITTER.get()).build(null)); public static <B extends Block> RegistryObject<Block> createBlock(String name, Supplier<? extends B> supplier, CreativeModeTab group) { return createBlock(name, supplier, null, group, 0); } public static <B extends Block> RegistryObject<Block> createBlock(String name, Supplier<? extends B> supplier, @Nullable String renderType, CreativeModeTab group) { return createBlock(name, supplier, renderType, group, 0); } public static <B extends Block> RegistryObject<Block> createBlock(String name, Supplier<? extends B> supplier, @Nullable String renderType, CreativeModeTab group, int burnTime) { RegistryObject<Block> block = ModBlock.BLOCKS.register(name, supplier); if (renderType != null) { RENDER_TYPE_DATA.add(new Pair<>(block, renderType)); } ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().tab(group)) { public int getBurnTime(ItemStack itemStack, RecipeType<?> recipeType) { return burnTime; } }); return block; } public static <B extends Block> RegistryObject<Block> createItemlessBlock(String name, Supplier<? extends B> supplier) { return createItemlessBlock(name, supplier, null); } public static <B extends Block> RegistryObject<Block> createItemlessBlock(String name, Supplier<? extends B> supplier, @Nullable String renderType) { RegistryObject<Block> block = ModBlock.BLOCKS.register(name, supplier); if (renderType != null) { RENDER_TYPE_DATA.add(new Pair<>(block, renderType)); } return block; } public static void registerRendering() { for (Pair<RegistryObject<Block>, String> i : RENDER_TYPE_DATA) { RenderType j = RenderType.cutout(); if (Objects.equals(i.getSecond(), "cutout")) j = RenderType.cutout(); else if (Objects.equals(i.getSecond(), "translucent")) j = RenderType.translucent(); ItemBlockRenderTypes.setRenderLayer(i.getFirst().get(), j); } } public static void registerBlockColors(){ BlockColors colors = Minecraft.getInstance().getBlockColors(); final BlockColor grassColor = (state, worldIn, pos, tintIndex) -> worldIn != null && pos != null ? BiomeColors.getAverageGrassColor(worldIn, pos) : GrassColor.get(0.5D, 1.0D); colors.register(grassColor, ModBlock.YARROW.get()); colors.register(grassColor, ModBlock.JUNEGRASS.get()); colors.register(grassColor, ModBlock.CANOLA.get()); } }
16,705
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModLootTables.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/init/ModLootTables.java
package untamedwilds.init; import net.minecraft.resources.ResourceLocation; import untamedwilds.UntamedWilds; public class ModLootTables { public static ResourceLocation LOOT_DIGGING = new ResourceLocation(UntamedWilds.MOD_ID, "gameplay/digging"); public static void init() { } }
294
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModEntity.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/init/ModEntity.java
package untamedwilds.init; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.event.entity.EntityAttributeCreationEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import untamedwilds.UntamedWilds; import untamedwilds.client.render.*; import untamedwilds.entity.ProjectileSpit; import untamedwilds.entity.amphibian.EntityGiantSalamander; import untamedwilds.entity.amphibian.EntityNewt; import untamedwilds.entity.arthropod.EntityKingCrab; import untamedwilds.entity.arthropod.EntityTarantula; import untamedwilds.entity.fish.*; import untamedwilds.entity.mammal.*; import untamedwilds.entity.mollusk.EntityGiantClam; import untamedwilds.entity.relict.EntitySpitter; import untamedwilds.entity.reptile.*; import untamedwilds.item.UntamedSpawnEggItem; import untamedwilds.world.FaunaHandler; import java.util.List; @Mod.EventBusSubscriber(modid = UntamedWilds.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModEntity { public final static DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, UntamedWilds.MOD_ID); //public static Map<RegistryObject<EntityType<? extends Mob>>, EntityRendererProvider<?>> map = Collections.emptyMap(); // Arthropods public static RegistryObject<EntityType<EntityTarantula>> TARANTULA = createEntity(EntityTarantula::new, "tarantula", 0.4f, 0.3f, 0xB5B095, 0x26292B); public static RegistryObject<EntityType<EntityKingCrab>> KING_CRAB = createEntity(EntityKingCrab::new, "king_crab", 0.6f, 0.5f, 0x715236, 0xAD9050); // Reptiles public static RegistryObject<EntityType<EntitySnake>> SNAKE = createEntity(EntitySnake::new, "snake", 0.95f, 0.3f, 0xD8A552, 0x5C3525); public static RegistryObject<EntityType<EntitySoftshellTurtle>> SOFTSHELL_TURTLE = createEntity(EntitySoftshellTurtle::new, "softshell_turtle", 0.6f, 0.3f, 0x828444, 0x26292B); public static RegistryObject<EntityType<EntityTortoise>> TORTOISE = createEntity(EntityTortoise::new, "tortoise", 0.6f, 0.6f, 0xAF9F74, 0x775232); public static RegistryObject<EntityType<EntityAnaconda>> ANACONDA = createEntity(EntityAnaconda::new, "large_snake", 1.5f, 0.6f, 0x65704C, 0x42291A); public static RegistryObject<EntityType<EntityMonitor>> MONITOR = createEntity(EntityMonitor::new, "monitor", 1.3f, 0.6f, 0x423C2C, 0x958C66); // Mollusks public static RegistryObject<EntityType<EntityGiantClam>> GIANT_CLAM = createEntity(EntityGiantClam::new, "giant_clam", 1.0F, 1.0F, 0x346B70, 0xAD713C); //public static RegistryObject<EntityType<EntityGiantClam>> GIANT_CLAM = createEntity(EntityGiantClam::new, MobCategory.WATER_CREATURE, "giant_clam", 32, 10, true, 1.0F, 1.0F, 0x346B70, 0xAD713C, animalType.SESSILE, 1); // Mammals public static RegistryObject<EntityType<EntityBear>> BEAR = createEntity(EntityBear::new, "bear", 1.3F, 1.3F, 0x20130B, 0x564C45); public static RegistryObject<EntityType<EntityBigCat>> BIG_CAT = createEntity(EntityBigCat::new, "big_cat", 1.2F, 1.0F, 0xC59F45,0x383121); public static RegistryObject<EntityType<EntityHippo>> HIPPO = createEntity(EntityHippo::new, "hippo", 1.8F, 1.8F, 0x463A31, 0x956761); public static RegistryObject<EntityType<EntityAardvark>> AARDVARK = createEntity(EntityAardvark::new, "aardvark", 0.9F, 0.9F, 0x463A31, 0x956761); public static RegistryObject<EntityType<EntityRhino>> RHINO = createEntity(EntityRhino::new, "rhino", 2.0F, 1.8F, 0x787676, 0x665956); public static RegistryObject<EntityType<EntityHyena>> HYENA = createEntity(EntityHyena::new, "hyena", 0.9F, 1.1F, 0x6C6857, 0x978966); public static RegistryObject<EntityType<EntityBoar>> BOAR = createEntity(EntityBoar::new, "boar", 1.2F, 1.2F, 0x503C2A, 0x605449); public static RegistryObject<EntityType<EntityBison>> BISON = createEntity(EntityBison::new, "bison", 1.7F, 1.6F, 0x845B2B, 0x49342A); public static RegistryObject<EntityType<EntityCamel>> CAMEL = createEntity(EntityCamel::new, "camel", 1.8F, 2F, 0xE0B989, 0x976B3D); public static RegistryObject<EntityType<EntityManatee>> MANATEE = createEntity(EntityManatee::new, "manatee", 1.8F, 2F, 0x4A4040, 0x787676); public static RegistryObject<EntityType<EntityBaleenWhale>> BALEEN_WHALE = createEntity(EntityBaleenWhale::new, "baleen_whale", 2.6F, 1.6F, 0x12141E, 0x5B6168); public static RegistryObject<EntityType<EntityOpossum>> OPOSSUM = createEntity(EntityOpossum::new, "opossum", 0.9F, 0.9F, 0xABA29B, 0x383735); // Fish public static RegistryObject<EntityType<EntitySunfish>> SUNFISH = createEntity(EntitySunfish::new, "sunfish", 1.6F, 1.6F, 0x2C545B, 0xB6D0D3); public static RegistryObject<EntityType<EntityTrevally>> TREVALLY = createEntity(EntityTrevally::new, "trevally", 0.8F, 0.8F, 0xA5B4AF, 0xC89D17); public static RegistryObject<EntityType<EntityArowana>> AROWANA = createEntity(EntityArowana::new, "arowana", 0.6F, 0.6F, 0x645C45, 0xB29F52); public static RegistryObject<EntityType<EntityShark>> SHARK = createEntity(EntityShark::new, "shark", 1.8F, 1.3F, 0x6B5142, 0xB0B0A3); public static RegistryObject<EntityType<EntityFootballFish>> FOOTBALL_FISH = createEntity(EntityFootballFish::new, "football_fish", 0.8F, 0.8F, 0x53556C, 0x2F3037); public static RegistryObject<EntityType<EntityWhaleShark>> WHALE_SHARK = createEntity(EntityWhaleShark::new, "whale_shark", 2.6F, 1.6F, 0x222426, 0x7E7D84); public static RegistryObject<EntityType<EntityTriggerfish>> TRIGGERFISH = createEntity(EntityTriggerfish::new, "triggerfish", 0.8F, 0.8F, 0x1F0A19, 0xFCBD00); public static RegistryObject<EntityType<EntityCatfish>> CATFISH = createEntity(EntityCatfish::new, "catfish", 0.8F, 0.8F, 0x545963, 0x3A2C23); public static RegistryObject<EntityType<EntitySpadefish>> SPADEFISH = createEntity(EntitySpadefish::new, "spadefish", 0.8F, 0.8F, 0x545963, 0x3A2C23); // Amphibians public static RegistryObject<EntityType<EntityGiantSalamander>> GIANT_SALAMANDER = createEntity(EntityGiantSalamander::new, "giant_salamander", 1F, 0.6f, 0x3A2C23, 0x6B5142); public static RegistryObject<EntityType<EntityNewt>> NEWT = createEntity(EntityNewt::new, "newt", 0.6F, 0.3f, 0x232323, 0xFF8D00); // Relicts public static RegistryObject<EntityType<EntitySpitter>> SPITTER = createEntity(EntitySpitter::new, "spitter", 1.3F, 1.3f, 0x3A345E, 0xB364E0); // Projectiles public static RegistryObject<EntityType<ProjectileSpit>> SPIT = createProjectile(ProjectileSpit::new, "spit", 64, 1, true,0.6F, 0.3f); private static <T extends Projectile> RegistryObject<EntityType<T>> createProjectile(EntityType.EntityFactory<T> factory, String name, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates, float sizeX, float sizeY) { RegistryObject<EntityType<T>> type = ENTITIES.register(name, () -> EntityType.Builder.of(factory, MobCategory.MISC) .sized(sizeX, sizeY) .clientTrackingRange(trackingRange) .setShouldReceiveVelocityUpdates(sendsVelocityUpdates) .build(name)); return type; } private static <T extends Mob> RegistryObject<EntityType<T>> createEntity(EntityType.EntityFactory<T> factory, String name, float sizeX, float sizeY, int baseColor, int overlayColor) { return createEntity(factory, MobCategory.CREATURE, name, 64, 1, true, sizeX, sizeY, baseColor, overlayColor); } private static <T extends Mob> RegistryObject<EntityType<T>> createEntity(EntityType.EntityFactory<T> factory, MobCategory classification, String name, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates, float sizeX, float sizeY, int maincolor, int backcolor) { RegistryObject<EntityType<T>> type = ENTITIES.register(name, () -> EntityType.Builder.of(factory, classification) .sized(sizeX, sizeY) .clientTrackingRange(trackingRange) .setShouldReceiveVelocityUpdates(sendsVelocityUpdates) .build(name)); ModItems.ITEMS.register(name + "_spawn_egg", () -> new UntamedSpawnEggItem(type, maincolor, backcolor, new Item.Properties().tab(CreativeModeTab.TAB_MISC))); return type; } @SubscribeEvent public static void bakeAttributes(EntityAttributeCreationEvent event) { event.put(TARANTULA.get(), EntityTarantula.registerAttributes().build()); event.put(KING_CRAB.get(), EntityKingCrab.registerAttributes().build()); event.put(SNAKE.get(), EntitySnake.registerAttributes().build()); event.put(SOFTSHELL_TURTLE.get(), EntitySoftshellTurtle.registerAttributes().build()); event.put(TORTOISE.get(), EntityTortoise.registerAttributes().build()); event.put(ANACONDA.get(), EntityAnaconda.registerAttributes().build()); event.put(MONITOR.get(), EntityMonitor.registerAttributes().build()); event.put(GIANT_CLAM.get(), EntityGiantClam.registerAttributes().build()); event.put(BEAR.get(), EntityBear.registerAttributes().build()); event.put(BIG_CAT.get(), EntityBigCat.registerAttributes().build()); event.put(HIPPO.get(), EntityHippo.registerAttributes().build()); event.put(AARDVARK.get(), EntityAardvark.registerAttributes().build()); event.put(RHINO.get(), EntityRhino.registerAttributes().build()); event.put(HYENA.get(), EntityHyena.registerAttributes().build()); event.put(BOAR.get(), EntityBoar.registerAttributes().build()); event.put(BISON.get(), EntityBison.registerAttributes().build()); event.put(CAMEL.get(), EntityCamel.registerAttributes().build()); event.put(MANATEE.get(), EntityManatee.registerAttributes().build()); event.put(BALEEN_WHALE.get(), EntityBaleenWhale.registerAttributes().build()); event.put(OPOSSUM.get(), EntityOpossum.registerAttributes().build()); event.put(SUNFISH.get(), EntitySunfish.registerAttributes().build()); event.put(TREVALLY.get(), EntityTrevally.registerAttributes().build()); event.put(AROWANA.get(), EntityArowana.registerAttributes().build()); event.put(SHARK.get(), EntityShark.registerAttributes().build()); event.put(FOOTBALL_FISH.get(), EntityFootballFish.registerAttributes().build()); event.put(WHALE_SHARK.get(), EntityWhaleShark.registerAttributes().build()); event.put(TRIGGERFISH.get(), EntityTriggerfish.registerAttributes().build()); event.put(CATFISH.get(), EntityCatfish.registerAttributes().build()); event.put(SPADEFISH.get(), EntitySpadefish.registerAttributes().build()); event.put(GIANT_SALAMANDER.get(), EntityGiantSalamander.registerAttributes().build()); event.put(NEWT.get(), EntityNewt.registerAttributes().build()); event.put(SPITTER.get(), EntitySpitter.registerAttributes().build()); } @SubscribeEvent public static void onRegisterRenderer(EntityRenderersEvent.RegisterRenderers event) { event.registerEntityRenderer(ModEntity.TARANTULA.get(), RendererTarantula::new); event.registerEntityRenderer(ModEntity.KING_CRAB.get(), RendererKingCrab::new); event.registerEntityRenderer(ModEntity.SOFTSHELL_TURTLE.get(), RendererSoftshellTurtle::new); event.registerEntityRenderer(ModEntity.SNAKE.get(), RendererSnake::new); event.registerEntityRenderer(ModEntity.TORTOISE.get(), RendererTortoise::new); event.registerEntityRenderer(ModEntity.ANACONDA.get(), RendererAnaconda::new); event.registerEntityRenderer(ModEntity.MONITOR.get(), RendererMonitor::new); event.registerEntityRenderer(ModEntity.GIANT_CLAM.get(), RendererGiantClam::new); event.registerEntityRenderer(ModEntity.BEAR.get(), RendererBear::new); event.registerEntityRenderer(ModEntity.BIG_CAT.get(), RendererBigCat::new); event.registerEntityRenderer(ModEntity.HIPPO.get(), RendererHippo::new); event.registerEntityRenderer(ModEntity.AARDVARK.get(), RendererAardvark::new); event.registerEntityRenderer(ModEntity.RHINO.get(), RendererRhino::new); event.registerEntityRenderer(ModEntity.HYENA.get(), RendererHyena::new); event.registerEntityRenderer(ModEntity.BOAR.get(), RendererBoar::new); event.registerEntityRenderer(ModEntity.BISON.get(), RendererBison::new); event.registerEntityRenderer(ModEntity.CAMEL.get(), RendererCamel::new); event.registerEntityRenderer(ModEntity.MANATEE.get(), RendererManatee::new); event.registerEntityRenderer(ModEntity.BALEEN_WHALE.get(), RendererBaleenWhale::new); event.registerEntityRenderer(ModEntity.OPOSSUM.get(), RendererOpossum::new); event.registerEntityRenderer(ModEntity.SUNFISH.get(), RendererSunfish::new); event.registerEntityRenderer(ModEntity.TREVALLY.get(), RendererTrevally::new); event.registerEntityRenderer(ModEntity.AROWANA.get(), RendererArowana::new); event.registerEntityRenderer(ModEntity.SHARK.get(), RendererShark::new); event.registerEntityRenderer(ModEntity.FOOTBALL_FISH.get(), RendererFootballFish::new); event.registerEntityRenderer(ModEntity.WHALE_SHARK.get(), RendererWhaleShark::new); event.registerEntityRenderer(ModEntity.TRIGGERFISH.get(), RendererTriggerfish::new); event.registerEntityRenderer(ModEntity.CATFISH.get(), RendererCatfish::new); event.registerEntityRenderer(ModEntity.SPADEFISH.get(), RendererSpadefish::new); event.registerEntityRenderer(ModEntity.GIANT_SALAMANDER.get(), RendererGiantSalamander::new); event.registerEntityRenderer(ModEntity.NEWT.get(), RendererNewt::new); event.registerEntityRenderer(ModEntity.SPITTER.get(), RendererSpitter::new); event.registerEntityRenderer(ModEntity.SPIT.get(), RendererProjectileSpit::new); } public static void addWorldSpawn(EntityType<?> entityClass, int weightedProb, FaunaHandler.animalType type, int groupCount) { List<FaunaHandler.SpawnListEntry> spawns = FaunaHandler.getSpawnableList(type); boolean found = false; for (FaunaHandler.SpawnListEntry entry : spawns) { // Adjusting an existing spawn entry if (entry.entityType == entityClass) { entry.itemWeight = weightedProb; //entry.groupCount = groupCount; found = true; break; } } //if (!found) //spawns.add(new FaunaHandler.SpawnListEntry(entityClass, weightedProb, groupCount)); } }
15,051
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModItems.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/init/ModItems.java
package untamedwilds.init; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.*; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.material.Fluids; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import untamedwilds.UntamedWilds; import untamedwilds.item.*; import untamedwilds.item.debug.*; import untamedwilds.util.ModCreativeModeTab; import java.util.function.Supplier; @SuppressWarnings("unused") @Mod.EventBusSubscriber(modid = UntamedWilds.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModItems { public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, UntamedWilds.MOD_ID); // Wild Level Item instances // Debug Tools public static RegistryObject<Item> LOGO = createItem("logo", () -> new Item(new Item.Properties().stacksTo(1).rarity(Rarity.EPIC))); public static RegistryObject<Item> OWNERSHIP_DEED = createItem("ownership_deed", () -> new OwnershipDeedItem(new Item.Properties().stacksTo(1).tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> DEBUG_ERASER = createItem("debug_eraser", () -> new EraserItem(new Item.Properties().stacksTo(1).tab(ModCreativeModeTab.untamedwilds_items).rarity(Rarity.EPIC))); public static RegistryObject<Item> DEBUG_ANALYZER = createItem("debug_analyzer", () -> new AnalyzerItem(new Item.Properties().stacksTo(1).tab(ModCreativeModeTab.untamedwilds_items).rarity(Rarity.EPIC))); public static RegistryObject<Item> DEBUG_IPECAC = createItem("debug_ipecac", () -> new IpecacItem(new Item.Properties().stacksTo(1).tab(ModCreativeModeTab.untamedwilds_items).rarity(Rarity.EPIC))); public static RegistryObject<Item> DEBUG_LOVE_POTION = createItem("debug_love_potion", () -> new LovePotionItem(new Item.Properties().stacksTo(1).tab(ModCreativeModeTab.untamedwilds_items).rarity(Rarity.EPIC))); public static RegistryObject<Item> DEBUG_GROWTH_TONIC = createItem("debug_growth_tonic", () -> new GrowthTonicItem(new Item.Properties().stacksTo(1).tab(ModCreativeModeTab.untamedwilds_items).rarity(Rarity.EPIC))); public static RegistryObject<Item> DEBUG_HIGHLIGHTER = createItem("debug_highlighter", () -> new HighlighterItem(new Item.Properties().stacksTo(1).tab(ModCreativeModeTab.untamedwilds_items).rarity(Rarity.EPIC))); // Materials public static RegistryObject<Item> MATERIAL_FAT = createItem("material_fat", () -> new LardItem(new Item.Properties().food((new FoodProperties.Builder()).nutrition(1).saturationMod(1F).meat().build()).tab(CreativeModeTab.TAB_FOOD))); public static RegistryObject<Item> MATERIAL_BLUBBER = createItem("material_blubber", () -> new LardItem(new Item.Properties().food((new FoodProperties.Builder()).nutrition(1).saturationMod(1F).meat().build()).tab(CreativeModeTab.TAB_FOOD)){ public int getBurnTime(ItemStack itemStack, RecipeType<?> recipeType) { return 1200; } }); public static RegistryObject<Item> MATERIAL_PEARL = createItem("material_pearl", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> RARE_GIANT_PEARL = createItem("material_giant_pearl", () -> new Item(new Item.Properties().rarity(Rarity.UNCOMMON).tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> MATERIAL_SNAKE_SKIN = createItem("material_snake_skin", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> CHUM = createItem("chum", () -> new ChumItem(new Item.Properties().food((new FoodProperties.Builder()).nutrition(1).saturationMod(0.1F).effect(() -> new MobEffectInstance(MobEffects.CONFUSION, 1200, 0), 1F).meat().build()).tab(CreativeModeTab.TAB_FOOD))); // Food public static RegistryObject<Item> MEAT_BEAR_RAW = createItem("food_bear_raw", () -> new Item(new Item.Properties().food((new FoodProperties.Builder()).nutrition(3).saturationMod(0.6F).meat().build()).tab(CreativeModeTab.TAB_FOOD))); public static RegistryObject<Item> MEAT_BEAR_COOKED = createItem("food_bear_cooked", () -> new Item(new Item.Properties().food((new FoodProperties.Builder()).nutrition(7).saturationMod(1F).meat().build()).tab(CreativeModeTab.TAB_FOOD))); public static RegistryObject<Item> MEAT_TURTLE_RAW = createItem("food_turtle_raw", () -> new Item(new Item.Properties().food((new FoodProperties.Builder()).nutrition(2).saturationMod(0.3F).meat().build()).tab(CreativeModeTab.TAB_FOOD))); public static RegistryObject<Item> MEAT_TURTLE_COOKED = createItem("food_turtle_cooked", () -> new Item(new Item.Properties().food((new FoodProperties.Builder()).nutrition(6).saturationMod(0.6F).meat().build()).tab(CreativeModeTab.TAB_FOOD))); public static RegistryObject<Item> MEAT_HIPPO_RAW = createItem("food_pachyderm_raw", () -> new Item(new Item.Properties().food((new FoodProperties.Builder()).nutrition(3).saturationMod(0.7F).meat().build()).tab(CreativeModeTab.TAB_FOOD))); public static RegistryObject<Item> MEAT_HIPPO_COOKED = createItem("food_pachyderm_cooked", () -> new Item(new Item.Properties().food((new FoodProperties.Builder()).nutrition(7).saturationMod(1.1F).meat().build()).tab(CreativeModeTab.TAB_FOOD))); public static RegistryObject<Item> FOOD_TURTLE_SOUP = createItem("food_turtle_soup", () -> new BowlFoodItem(new Item.Properties().food((new FoodProperties.Builder()).nutrition(8).saturationMod(0.6F).build()).tab(CreativeModeTab.TAB_FOOD).stacksTo(1))); public static RegistryObject<Item> FOOD_PEMMICAN = createItem("food_pemmican", () -> new Item(new Item.Properties().food((new FoodProperties.Builder()).nutrition(6).saturationMod(1.0F).build()).tab(CreativeModeTab.TAB_FOOD))); public static RegistryObject<Item> VEGETABLE_AARDVARK_CUCUMBER = createItem("food_aardvark_cucumber", () -> new Item(new Item.Properties().food((new FoodProperties.Builder()).nutrition(3).saturationMod(0.2F).build()).tab(CreativeModeTab.TAB_FOOD))); public static RegistryObject<Item> FOOD_HEMLOCK_STEW = createItem("food_hemlock_stew", () -> new BowlFoodItem(new Item.Properties().food((new FoodProperties.Builder()).nutrition(6).saturationMod(0.1F).effect(() -> new MobEffectInstance(MobEffects.POISON, 1200, 3), 1.0F).alwaysEat().build()).tab(CreativeModeTab.TAB_FOOD).stacksTo(1))); // Hides public static RegistryObject<Item> HIDE_BEAR_ASHEN = createItem("hide_bear_ashen", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> HIDE_BEAR_BLACK = createItem("hide_bear_black", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> HIDE_BEAR_BROWN = createItem("hide_bear_brown", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> HIDE_BEAR_WHITE = createItem("hide_bear_white", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> HIDE_BIGCAT_JAGUAR = createItem("hide_bigcat_jaguar", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> HIDE_BIGCAT_LEOPARD = createItem("hide_bigcat_leopard", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> HIDE_BIGCAT_LION = createItem("hide_bigcat_lion", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> HIDE_BIGCAT_PANTHER = createItem("hide_bigcat_panther", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> HIDE_BIGCAT_PUMA = createItem("hide_bigcat_puma", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> HIDE_BIGCAT_SNOW_LEOPARD = createItem("hide_bigcat_snow_leopard", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static RegistryObject<Item> HIDE_BIGCAT_TIGER = createItem("hide_bigcat_tiger", () -> new Item(new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Item Blocks public static RegistryObject<Item> SEED_TITAN_ARUM = createItem("flora_titan_arum_corm", () -> new ItemNameBlockItem(ModBlock.TITAN_ARUM.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); public static RegistryObject<Item> SEED_ZIMBABWE_ALOE = createItem("flora_zimbabwe_aloe_sapling", () -> new ItemNameBlockItem(ModBlock.ZIMBABWE_ALOE.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); public static RegistryObject<Item> WATER_HYACINTH_BLOCK = createItem("flora_water_hyacinth_item", () -> new WaterLilyBlockItem(ModBlock.WATER_HYACINTH.get(), new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); public static <I extends Item> RegistryObject<I> createItem(String name, Supplier<? extends I> supplier) { return ModItems.ITEMS.register(name, supplier); } public static void registerSpawnItems() { // These items have no associated objects, as they are not supposed to be accessed, and I do not want to register each variant // Tarantula Items ModItems.ITEMS.register("egg_tarantula", () -> new MobEggItem(ModEntity.TARANTULA, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("bottle_tarantula", () -> new MobBottledItem(ModEntity.TARANTULA, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Small Snake Items ModItems.ITEMS.register("egg_snake", () -> new MobEggItem(ModEntity.SNAKE, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("spawn_snake", () -> new MobSpawnItem(ModEntity.SNAKE, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Softshell Turtle Items ModItems.ITEMS.register("egg_softshell_turtle", () -> new MobEggItem(ModEntity.SOFTSHELL_TURTLE, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("spawn_softshell_turtle", () -> new MobSpawnItem(ModEntity.SOFTSHELL_TURTLE, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Giant Clam Items ModItems.ITEMS.register("egg_giant_clam", () -> new MobEggItem(ModEntity.GIANT_CLAM, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("spawn_giant_clam", () -> new MobSpawnItem(ModEntity.GIANT_CLAM, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Sunfish Items ModItems.ITEMS.register("egg_sunfish", () -> new MobEggItem(ModEntity.SUNFISH, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Trevally Items ModItems.ITEMS.register("egg_trevally", () -> new MobEggItem(ModEntity.TREVALLY, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("bucket_trevally", () -> new MobBucketedItem(ModEntity.TREVALLY, Fluids.WATER, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Arowana Items ModItems.ITEMS.register("egg_arowana", () -> new MobEggItem(ModEntity.AROWANA, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("bucket_arowana", () -> new MobBucketedItem(ModEntity.AROWANA, Fluids.WATER, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Football Fish Items ModItems.ITEMS.register("egg_football_fish", () -> new MobEggItem(ModEntity.FOOTBALL_FISH, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("bucket_football_fish", () -> new MobBucketedItem(ModEntity.FOOTBALL_FISH, Fluids.WATER, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Giant Salamander Items ModItems.ITEMS.register("egg_giant_salamander", () -> new MobEggItem(ModEntity.GIANT_SALAMANDER, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("bucket_giant_salamander", () -> new MobBucketedItem(ModEntity.GIANT_SALAMANDER, Fluids.WATER, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Newt Items ModItems.ITEMS.register("egg_newt", () -> new MobEggItem(ModEntity.NEWT, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("bucket_newt", () -> new MobBucketedItem(ModEntity.NEWT, Fluids.WATER, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Tortoise Items ModItems.ITEMS.register("egg_tortoise", () -> new MobEggItem(ModEntity.TORTOISE, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("spawn_tortoise", () -> new MobSpawnItem(ModEntity.TORTOISE, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Large Snake Items ModItems.ITEMS.register("egg_large_snake", () -> new MobEggItem(ModEntity.ANACONDA, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Triggerfish Items ModItems.ITEMS.register("egg_triggerfish", () -> new MobEggItem(ModEntity.TRIGGERFISH, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("bucket_triggerfish", () -> new MobBucketedItem(ModEntity.TRIGGERFISH, Fluids.WATER, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Catfish Items ModItems.ITEMS.register("egg_catfish", () -> new MobEggItem(ModEntity.CATFISH, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("bucket_catfish", () -> new MobBucketedItem(ModEntity.CATFISH, Fluids.WATER, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // King Crab Items ModItems.ITEMS.register("egg_king_crab", () -> new MobEggItem(ModEntity.KING_CRAB, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("bucket_king_crab", () -> new MobBucketedItem(ModEntity.KING_CRAB, Fluids.WATER, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Monitor Items ModItems.ITEMS.register("egg_monitor", () -> new MobEggItem(ModEntity.MONITOR, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); // Spadefish Items ModItems.ITEMS.register("egg_spadefish", () -> new MobEggItem(ModEntity.SPADEFISH, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); ModItems.ITEMS.register("bucket_spadefish", () -> new MobBucketedItem(ModEntity.SPADEFISH, Fluids.WATER, new Item.Properties().tab(ModCreativeModeTab.untamedwilds_items))); } }
15,267
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModParticles.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/init/ModParticles.java
package untamedwilds.init; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.ParticleEngine; import net.minecraft.core.particles.ParticleType; import net.minecraft.core.particles.SimpleParticleType; import net.minecraftforge.client.event.ParticleFactoryRegisterEvent; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import untamedwilds.UntamedWilds; import untamedwilds.client.particle.ChumParticle; @Mod.EventBusSubscriber(modid = UntamedWilds.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModParticles { public static final SimpleParticleType CHUM_DISPERSE = new SimpleParticleType(true); @SubscribeEvent public static void registerParticleFactories(ParticleFactoryRegisterEvent event) { ParticleEngine manager = Minecraft.getInstance().particleEngine; manager.register(CHUM_DISPERSE, ChumParticle.Provider::new); } @SubscribeEvent public static void registerParticleTypes(RegistryEvent.Register<ParticleType<?>> evt) { CHUM_DISPERSE.setRegistryName(UntamedWilds.MOD_ID, "chum"); evt.getRegistry().registerAll(CHUM_DISPERSE); } }
1,231
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ModAdvancementTriggers.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/init/ModAdvancementTriggers.java
package untamedwilds.init; import com.google.gson.JsonObject; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.advancements.CriterionTriggerInstance; import net.minecraft.advancements.critereon.*; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import untamedwilds.UntamedWilds; public class ModAdvancementTriggers { public static UntamedTriggers<?> NO_PATCHOULI_LOADED = new UntamedTriggers<>(new ResourceLocation(UntamedWilds.MOD_ID, "guidebook_alt")); public static UntamedTriggers<?> BAIT_BASIC = new UntamedTriggers<>(new ResourceLocation(UntamedWilds.MOD_ID, "used_bait")); public static UntamedTriggers<?> MASTER_BAIT = new UntamedTriggers<>(new ResourceLocation(UntamedWilds.MOD_ID, "master_bait")); // TODO: Abstract the "Discovered" Trigger to activate for any mob public static UntamedTriggers<?> DISCOVERED_SPITTER = new UntamedTriggers<>(new ResourceLocation(UntamedWilds.MOD_ID, "discovered_spitter")); public static void register() { CriteriaTriggers.register(NO_PATCHOULI_LOADED); CriteriaTriggers.register(BAIT_BASIC); CriteriaTriggers.register(MASTER_BAIT); CriteriaTriggers.register(DISCOVERED_SPITTER); } public static class UntamedTriggers<T extends CriterionTriggerInstance> extends SimpleCriterionTrigger<UntamedTriggers.Instance> { private final ResourceLocation id; public UntamedTriggers(ResourceLocation resourceLocation) { this.id = resourceLocation; } public Instance createInstance(JsonObject objectIn, EntityPredicate.Composite predicateIn, DeserializationContext p_230241_3_) { return new UntamedTriggers.Instance(predicateIn, id); } public void trigger(ServerPlayer entityIn) { this.trigger(entityIn, (input) -> true); } @Override public ResourceLocation getId() { return id; } public static class Instance extends AbstractCriterionTriggerInstance { public Instance(EntityPredicate.Composite p_i231507_1_, ResourceLocation res) { super(res, p_i231507_1_); } public JsonObject serializeToJson(SerializationContext p_230240_1_) { return super.serializeToJson(p_230240_1_); } } } }
2,390
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
IPackEntity.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/IPackEntity.java
package untamedwilds.entity; import untamedwilds.util.EntityUtils; public interface IPackEntity { static void initPack(ComplexMob entity) { entity.herd = new HerdEntity(entity, EntityUtils.getPackSize(entity.getType(), entity.getVariant())); } default boolean shouldLeavePack() { return false; } }
334
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
HerdEntity.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/HerdEntity.java
package untamedwilds.entity; import net.minecraft.world.phys.Vec3; import java.util.ArrayList; import java.util.List; import java.util.Random; public class HerdEntity { private int maxHerdSize; private float radius = 8.0F; private boolean openToCombine; private ComplexMob leader; private final Random rand; public final List<ComplexMob> creatureList = new ArrayList<>(); public double splitOffDistance = 1024D; public HerdEntity(ComplexMob creature, int maxSize) { this.openToCombine = true; this.rand = new Random(); this.maxHerdSize = maxSize; this.setLeader(creature); } public void setLeader(ComplexMob creature) { this.leader = creature; if (!this.containsCreature(this.leader)) { this.addCreature(this.leader); } } public void chooseRandomLeader() { this.setLeader(this.creatureList.get(this.rand.nextInt(this.creatureList.size()))); } public ComplexMob getLeader() { return this.leader; } public void addCreature(ComplexMob creature) { if (!this.creatureList.contains(creature)) { this.creatureList.add(creature); } } public boolean containsCreature(ComplexMob creature) { return this.creatureList.contains(creature); } public void removeCreature(HerdEntity herd, ComplexMob creature) { herd.creatureList.remove(creature); if (herd.creatureList.size() > 0 && herd.getLeader() == creature) { herd.chooseRandomLeader(); } if (creature instanceof IPackEntity) { IPackEntity.initPack(creature); //creature.herd.setOpenToCombine(false); } } public void setMaxSize(int maxSchoolSize) { this.maxHerdSize = maxSchoolSize; } public int getMaxSize() { return this.maxHerdSize; } public void setRadius(float radius) { this.radius = radius; } public float getRadius() { return this.radius; } public void setOpenToCombine(boolean openToCombine) { this.openToCombine = openToCombine; } private boolean isOpenToCombine() { return this.openToCombine; } public void tick() { if (this.creatureList.size() == this.getMaxSize()) { this.setOpenToCombine(false); } else if (this.rand.nextInt(1800) == 0) { this.setOpenToCombine(!this.isOpenToCombine()); } if (this.getLeader().tickCount % 10 == 0) { List<ComplexMob> toRemove = new ArrayList<>(); if (this.isOpenToCombine()) { List<ComplexMob> list = this.getLeader().getLevel().getEntitiesOfClass(ComplexMob.class, this.getLeader().getBoundingBox().inflate(16.0D, 12.0D, 16.0D)); for (ComplexMob creature : list) { if (!this.containsCreature(creature) && creature.herd != null && canCombineHerds(this, creature.herd)) { int netSize = this.creatureList.size() + creature.herd.creatureList.size(); if (creature.herd.isOpenToCombine() && creature.getClass().equals(this.getLeader().getClass()) && netSize <= this.getMaxSize() && netSize <= creature.herd.getMaxSize()) { combineHerds(this, creature.herd); } } } } ComplexMob creature; for (ComplexMob complexMob : this.creatureList) { creature = complexMob; /*if (creature instanceof IPackEntity) { IPackEntity packCreature = (IPackEntity)creature; if (packCreature.shouldLeavePack()) { toRemove.add(creature); continue; } }*/ if (creature.isAlive() && creature.distanceToSqr(this.leader) <= this.splitOffDistance) { if (creature != this.leader) { if (creature.distanceToSqr(this.leader) <= (double) (this.radius * this.radius)) { Vec3 vec = this.leader.getLookAngle(); creature.getLookControl().setLookAt(creature.getX() + vec.x, creature.getY() + vec.y, creature.getZ() + vec.z, 6.0F, 85.0F); } } } else { toRemove.add(creature); } } for (ComplexMob mob : toRemove) { removeCreature(this, mob); } } } static boolean canCombineHerds(HerdEntity thisPack, HerdEntity otherPack) { return thisPack.creatureList.size() + otherPack.creatureList.size() <= thisPack.getMaxSize(); } public static void combineHerds(HerdEntity herd1, HerdEntity herd2) { if (herd2.creatureList.size() > herd1.creatureList.size()) { herd1.setLeader(herd2.getLeader()); } if (herd2.getMaxSize() < herd1.getMaxSize()) { herd1.setMaxSize(herd2.getMaxSize()); } if (herd2.getRadius() < herd1.getRadius()) { herd1.setRadius(herd2.getRadius()); } herd1.creatureList.addAll(herd2.creatureList); } }
5,306
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ComplexMobTerrestrial.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ComplexMobTerrestrial.java
package untamedwilds.entity; import com.github.alexthe666.citadel.animation.Animation; import com.github.alexthe666.citadel.animation.AnimationHandler; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.ai.control.look.SmartLandLookControl; import untamedwilds.util.EntityUtils; public abstract class ComplexMobTerrestrial extends ComplexMob implements IAnimatedEntity { public int sitProgress; // A counter which defines the progress towards the Sitting Poses public int ticksToSit; public int sleepProgress; // A counter which defines the progress towards the Sleeping Poses public int forceSleep; // Negative forceSleep keeps the mob awake, Positive forceSleep keeps the mob asleep protected int tiredCounter = 0; protected int buoyancy = 1; private static final EntityDataAccessor<Integer> HUNGER = SynchedEntityData.defineId(ComplexMobTerrestrial.class, EntityDataSerializers.INT); private int animationTick; private Animation currentAnimation; public float turn_speed = 0.2F; protected float swimSpeedMult = 1.0F; public ComplexMobTerrestrial(EntityType<? extends ComplexMob> type, Level worldIn){ super(type, worldIn); this.moveControl = new MoveControl(this); this.lookControl = new SmartLandLookControl(this, 30); this.ticksToSit = 40; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(HUNGER, 79); // One point less than the breeding threshold } public void aiStep() { AnimationHandler.INSTANCE.updateAnimations(this); if (!level.isClientSide) { if (this.forceSleep > 0) { this.forceSleep--; } else if (this.forceSleep < 0) { this.forceSleep++; } if (!this.getNavigation().isDone() && (this.isSitting() || this.isSleeping())) { this.setSitting(false); this.setSleeping(false); } if (this.getAirSupply() < 40 && this.tickCount % 10 == 0) { // TODO: There's probably a better place to dump this (mobs about to drown will go to the surface for air), but it refuses to work everywhere else this.getMoveControl().strafe(0.6F, 0); this.jumpFromGround(); } if (!this.isSleeping() && this.forceSleep > 0) { this.setSleeping(true); } if (this.tickCount % 200 == 0) { if (!this.isActive() && this.getNavigation().isDone()) { this.tiredCounter++; if (this.distanceToSqr(this.getHomeAsVec()) <= 6) { this.setSleeping(true); this.tiredCounter = 0; } else if (tiredCounter >= 3) { this.setHome(BlockPos.ZERO); this.tiredCounter = 0; } this.moveControl.setWantedPosition(this.getHome().getX(), this.getHome().getY(), this.getHome().getZ(), 1f); } } } if (this.isSitting() && this.sitProgress < this.ticksToSit) { this.sitProgress++; } else if (!this.isSitting() && this.sitProgress > 0) { this.sitProgress--; } if (this.isSleeping() && this.sleepProgress < 40) { this.sleepProgress++; } else if (!this.isSleeping() && this.sleepProgress > 0) { this.sleepProgress--; } super.aiStep(); } public InteractionResult mobInteract(Player player, InteractionHand hand) { if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { ItemStack itemstack = player.getItemInHand(hand); if (!this.isBaby() && this.isFood(itemstack) && !this.dead) { if (!this.level.isClientSide && !player.isCreative()) { itemstack.shrink(1); } if (ConfigGamerules.playerBreeding.get() && this.age == 0) { this.setInLove(player); EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.HEART, 7, 1); } this.setAnimation(this.getAnimationEat()); this.playSound(SoundEvents.GENERIC_EAT, 1F, 1); return InteractionResult.CONSUME; } } return super.mobInteract(player, hand); } protected ActivityType getActivityType() { return getEntityData(this.getType()).getActivityType(this.getVariant()); } public boolean isActive() { ActivityType type = this.getActivityType(); Pair<Integer, Integer> times = type.getTimes(); if ((this.isTame() && this.getCommandInt() != 0) || !ConfigGamerules.sleepBehaviour.get()) { return true; } if (type == ActivityType.CATHEMERAL) { return this.tickCount % 17000 < 3000; } long time = this.level.getDayTime(); if (!times.getFirst().equals(times.getSecond())) { if (times.getFirst() > times.getSecond()) { return time > times.getFirst() || time < times.getSecond(); } else { return time > times.getFirst() && time < times.getSecond(); } } return this.forceSleep >= 0; } public enum ActivityType { DIURNAL ("diurnal", 1000, 16000), // From 7 AM to 10 PM NOCTURNAL ("nocturnal", 13000, 4000), // From 7 PM to 10 AM CREPUSCULAR ("crepuscular", 8000, 23000), // From 14 PM to 5 AM ; 4000 - 19000 ??? CATHEMERAL ("cathemeral", -1, -1), // Random naps throughout the day INSOMNIAC ("insomniac", -1, -1); // No sleep, redundant, should just not add the GoToSleepGoal public int wakeUp; public int sleep; public String name; public static final Codec<ActivityType> CODEC = Codec.STRING.comapFlatMap(ActivityType::getByName, ActivityType::toString).stable(); ActivityType(String name, int wakeUp, int sleep) { this.wakeUp = wakeUp; this.sleep = sleep; this.name = name; } private static DataResult<ActivityType> getByName(String path) { return switch (path) { case "diurnal" -> DataResult.success(DIURNAL); case "nocturnal" -> DataResult.success(NOCTURNAL); case "crepuscular" -> DataResult.success(CREPUSCULAR); case "cathemeral" -> DataResult.success(CATHEMERAL); default -> DataResult.success(INSOMNIAC); }; } public String toString() { return this.name; } public Pair<Integer, Integer> getTimes() { return new Pair<>(this.wakeUp, this.sleep); } } private void setHunger(int hunger){ this.entityData.set(HUNGER, hunger); } public int getHunger(){ return (this.entityData.get(HUNGER)); } public boolean isStarving() { return this.getHunger() <= 0; } public void addHunger(int change) { int i = this.getHunger() + change; this.setHunger((i > 200) ? 200 : (Math.max(i, 0))); } public boolean hurt(DamageSource source, float amount) { if (this.isSitting()) { this.setSitting(false); } if (this.isSleeping() && this.forceSleep <= 0) { this.setSleeping(false); this.forceSleep = -4000; } return super.hurt(source, amount); } public void die(DamageSource p_70645_1_) { if (!this.level.isClientSide && !ConfigGamerules.hardcoreDeath.get() && this.getHome() != BlockPos.ZERO && this.isTame() && this.getHunger() != 0) { this.addEffect(new MobEffectInstance(MobEffects.GLOWING, 800, 0)); this.setHealth(0.5F); this.setHunger(0); if (!this.randomTeleport(this.getHome().getX(), this.getHome().getY(), this.getHome().getZ(), true)){ super.die(p_70645_1_); } } else { super.die(p_70645_1_); } } public void travel(Vec3 p_30218_) { if (this.isEffectiveAi() && this.isInWater()) { this.moveRelative(0.025F, p_30218_); 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(p_30218_); } } @Override public int getAnimationTick() { return animationTick; } @Override public void setAnimationTick(int tick) { animationTick = tick; } @Override public Animation getAnimation() { return currentAnimation; } @Override public void setAnimation(Animation animation) { currentAnimation = animation; } @Override public Animation[] getAnimations() { return new Animation[]{}; } public Animation getAnimationEat() { return this.NO_ANIMATION; } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("Sleeping", this.isSleeping()); compound.putInt("SleepingTicks", this.forceSleep); compound.putBoolean("Sitting", this.isSitting()); compound.putInt("Hunger", this.getHunger()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setSleeping(compound.getBoolean("Sleeping")); this.forceSleep = compound.getInt("SleepingTicks"); this.setSitting(compound.getBoolean("Sitting")); this.setHunger(compound.getInt("Hunger")); } /*static class MoveHelperController extends MoveControl { private final ComplexMobTerrestrial entity; MoveHelperController(ComplexMobTerrestrial turtleIn) { super(turtleIn); this.entity = turtleIn; } @Override public void tick() { if (this.action == MovementController.Action.STRAFE) { float f = (float)this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue(); float f1 = (float)this.speed * f; float f2 = this.moveForward; float f3 = this.moveStrafe; float f4 = Mth.sqrt(f2 * f2 + f3 * f3); if (f4 < 1.0F) { f4 = 1.0F; } f4 = f1 / f4; f2 = f2 * f4; f3 = f3 * f4; float f5 = Mth.sin(this.entity.rotationYaw * ((float)Math.PI / 180F)); float f6 = Mth.cos(this.entity.rotationYaw * ((float)Math.PI / 180F)); float f7 = f2 * f6 - f3 * f5; float f8 = f3 * f6 + f2 * f5; PathNavigator pathnavigator = this.entity.getNavigation(); NodeProcessor nodeprocessor = pathnavigator.getNodeProcessor(); if (nodeprocessor.getPathNodeType(this.entity.world, Mth.floor(this.entity.getX() + (double) f7), Mth.floor(this.entity.getY()), Mth.floor(this.entity.getZ() + (double) f8)) != PathNodeType.WALKABLE) { this.moveForward = (float) this.getSpeed(); // EDITED: was hardcoded to 1.0F this.moveStrafe = 0.0F; f1 = f; } this.entity.setAIMoveSpeed(f1); this.entity.setMoveForward(this.moveForward); this.entity.setMoveStrafing(this.moveStrafe); this.action = MovementController.Action.WAIT; } else if (this.action == MovementController.Action.MOVE_TO) { this.action = MovementController.Action.WAIT; double d0 = this.posX - this.entity.getX(); double d1 = this.posZ - this.entity.getZ(); double d2 = this.posY - this.entity.getY(); double d3 = d0 * d0 + d2 * d2 + d1 * d1; if (d3 < (double)2.5000003E-7F) { this.entity.setMoveForward(0.0F); return; } float f = (float)(Mth.atan2(d1, d0) * (double)(180F / (float)Math.PI)) - 90.0F; this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw, f, this.entity.turn_speed * 100); BlockPos blockpos = this.entity.getPosition(); BlockState blockstate = this.entity.world.getBlockState(blockpos); Block block = blockstate.getBlock(); VoxelShape voxelshape = blockstate.getCollisionShape(this.entity.world, blockpos); if (this.entity.isInWater()) { if (this.entity.collidedHorizontally && this.entity.tickCount % 10 == 0) { this.entity.jump(); } //this.entity.setDeltaMovement(this.entity.getDeltaMovement().scale(1.1)); float f2 = -((float)(Mth.atan2(d1, Mth.sqrt(d0 * d0 + d2 * d2)) * (double)(180F / (float)Math.PI))); f2 = Mth.clamp(Mth.wrapDegrees(f2), -85.0F, 85.0F); this.entity.getXRot() = this.limitAngle(this.entity.getXRot(), f2, 1.0F); float f4 = Mth.sin(this.entity.getXRot() * ((float)Math.PI / 180F)); this.entity.moveVertical = -f4 * (float)this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue(); if (this.entity.getTarget() == null) { this.entity.setDeltaMovement(this.entity.getDeltaMovement().add(0.0D, this.entity.buoyancy - 1, 0.0D)); } //this.entity.getXRot() = this.limitAngle(this.entity.getXRot(), (float) (this.entity.getDeltaMovement().getY() * -40), 0.1F); } //((ServerWorld)this.entity.world).spawnParticle(ParticleTypes.POOF, this.getX(), this.getY(), this.getZ(), 1, 0, 0, 0, 0.15F); float f1 = (float)(this.getSpeed() * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue()); this.entity.setAIMoveSpeed(Mth.lerp(0.125F, this.entity.getAIMoveSpeed(), f1)); if (d2 > (double)this.entity.maxUpStep && d0 * d0 + d1 * d1 < (double)Math.max(1.0F, this.entity.getBbWidth()) || !voxelshape.isEmpty() && this.entity.getY() < voxelshape.getEnd(Direction.Axis.Y) + (double)blockpos.getY() && !block.isIn(BlockTags.DOORS) && !block.isIn(BlockTags.FENCES)) { this.entity.getJumpControl().jump(); this.action = MovementController.Action.JUMPING; } } else if (this.action == MovementController.Action.JUMPING) { this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue())); if (this.entity.onGround) { this.action = MovementController.Action.WAIT; } } else { if (this.entity.isInWater() && this.entity.getTarget() == null && !this.entity.collidedHorizontally) { this.entity.setDeltaMovement(this.entity.getDeltaMovement().add(0.0D, this.entity.buoyancy - 1, 0.0D)); } this.entity.setMoveForward(0.0F); } } }*/ }
16,737
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ComplexMobAquatic.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ComplexMobAquatic.java
package untamedwilds.entity; import com.mojang.math.Vector3d; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.behavior.BehaviorUtils; import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.ai.control.SmoothSwimmingLookControl; import net.minecraft.world.entity.ai.control.SmoothSwimmingMoveControl; import net.minecraft.world.entity.ai.goal.PanicGoal; import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal; import net.minecraft.world.entity.ai.navigation.PathNavigation; import net.minecraft.world.entity.ai.navigation.WaterBoundPathNavigation; import net.minecraft.world.entity.ai.util.DefaultRandomPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.phys.Vec3; import untamedwilds.UntamedWilds; import javax.annotation.Nullable; public abstract class ComplexMobAquatic extends ComplexMob { public ComplexMobAquatic(EntityType<? extends ComplexMob> entity, Level worldIn) { super(entity, worldIn); this.setPathfindingMalus(BlockPathTypes.WATER, 0.0F); this.moveControl = new SmoothSwimmingMoveControl(this, 85, 10, 0.02F, 0.1F, true); this.lookControl = new SmoothSwimmingLookControl(this, 10); } @Override public void onInsideBubbleColumn(boolean downwards) {} public boolean canBreatheUnderwater() { return true; } public MobType getMobType() { return MobType.WATER; } protected float getStandingEyeHeight(Pose p_213348_1_, EntityDimensions p_213348_2_) { return p_213348_2_.height * 0.2F; } public void baseTick() { int i = this.getAirSupply(); super.baseTick(); this.updateAir(i); } protected void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(0, new PanicGoal(this, 1.25D)); } protected PathNavigation createNavigation(Level worldIn) { return new WaterBoundPathNavigation(this, worldIn); } public void aiStep() { if (!this.isInWater() && this.isOnGround() && this.verticalCollision) { this.setDeltaMovement(this.getDeltaMovement().add(((this.random.nextFloat() * 2.0F - 1.0F) * 0.05F), 0.4000000059604645D, ((this.random.nextFloat() * 2.0F - 1.0F) * 0.05F))); this.setOnGround(false); this.playSound(this.getFlopSound(), this.getSoundVolume(), this.getVoicePitch()); } super.aiStep(); } protected void updateAir(int air) { if (this.isAlive() && !this.isInWaterOrBubble()) { this.setAirSupply(air - 1); if (this.getAirSupply() == -20) { this.setAirSupply(0); this.hurt(DamageSource.DROWN, 2.0F); } } else { this.setAirSupply(300); } } public boolean isPushedByFluid() { return false; } protected abstract SoundEvent getFlopSound(); protected SoundEvent getSwimSound() { return SoundEvents.FISH_SWIM; } public void travel(Vec3 movement) { if (!this.level.isClientSide() && this.isInWater()) { this.moveRelative(this.getSpeed(), movement); 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(movement); } } /*public static class MoveHelperController extends MoveControl { private final ComplexMob entity; private final float landMoveFactor; public MoveHelperController(ComplexMob entity) { super(entity); this.entity = entity; this.landMoveFactor = 0.1F; } public MoveHelperController(ComplexMob entity, float landMoveFactor) { super(entity); this.entity = entity; this.landMoveFactor = landMoveFactor; } public void tick() { if (this.entity.isInWater()) { this.entity.setDeltaMovement(this.entity.getDeltaMovement().add(0.0D, 0.0045D, 0.0D)); } if (this.action == MovementController.Action.MOVE_TO && !this.entity.getNavigation().isDone()) { double d0 = this.getX() - this.entity.getX(); double d1 = this.getY() - this.entity.getY(); double d2 = this.getZ() - this.entity.getZ(); double d3 = d0 * d0 + d1 * d1 + d2 * d2; if (d3 < (double)2.5000003E-7F) { this.mob.setMoveForward(0.0F); } else { float f = (float)(Mth.atan2(d2, d0) * (double)(180F / (float)Math.PI)) - 90.0F; this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw, f, this.entity.turn_speed * 10); this.entity.renderYawOffset = this.entity.rotationYaw; this.entity.rotationYawHead = this.entity.rotationYaw; float f1 = (float)(this.speed * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue()); if (this.entity.isInWater()) { this.entity.setAIMoveSpeed(f1 * 0.02F); float f2 = -((float)(Mth.atan2(d1, Mth.sqrt(d0 * d0 + d2 * d2)) * (double)(180F / (float)Math.PI))); f2 = Mth.clamp(Mth.wrapDegrees(f2), -85.0F, 85.0F); this.entity.getXRot() = this.limitAngle(this.entity.getXRot(), f2, 5.0F); float f3 = Mth.cos(this.entity.getXRot() * ((float)Math.PI / 180F)); float f4 = Mth.sin(this.entity.getXRot() * ((float)Math.PI / 180F)); this.entity.moveForward = f3 * f1; this.entity.moveVertical = -f4 * f1; } else { this.entity.setAIMoveSpeed(f1 * landMoveFactor); } } } else { this.entity.setAIMoveSpeed(0.0F); this.entity.setMoveStrafing(0.0F); this.entity.setMoveVertical(0.0F); this.entity.setMoveForward(0.0F); } } }*/ protected static class SwimGoal extends RandomSwimmingGoal { public int heightFromBottom; public SwimGoal(ComplexMobAquatic entity) { this(entity, -1); } public SwimGoal(ComplexMobAquatic entity, int offset) { super(entity, 1.0D, 20); this.heightFromBottom = offset; } public boolean canUse() { return super.canUse(); } @Nullable protected Vec3 getPosition() { Vec3 vector3d = BehaviorUtils.getRandomSwimmablePos(this.mob, 10, 7); //UntamedWilds.LOGGER.info((vector3d != null) + " " + (this.heightFromBottom > 0) + " " + this.mob.level.canSeeSkyFromBelowWater(this.mob.blockPosition())); if (vector3d != null && this.heightFromBottom > 0 && this.mob.level.canSeeSkyFromBelowWater(this.mob.blockPosition())) { int offset = this.heightFromBottom + this.mob.level.getRandom().nextInt(7) - 4; //UntamedWilds.LOGGER.info(vector3d); //((ServerLevel)this.mob.level).sendParticles(ParticleTypes.GLOW, vector3d.x(), this.mob.level.getHeight(Heightmap.Types.OCEAN_FLOOR, (int)vector3d.x(), (int)vector3d.z()) + offset, vector3d.z() + 0.5, 50, 0.0D, 0.0D, 0.0D, 0.15F); return new Vec3(vector3d.x(), this.mob.level.getHeight(Heightmap.Types.OCEAN_FLOOR, (int)vector3d.x(), (int)vector3d.z()) + offset, vector3d.z()); } return vector3d; } } }
8,423
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
INeedsPostUpdate.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/INeedsPostUpdate.java
package untamedwilds.entity; /** * Interface reserved for mobs which need to have their attributes updated after spawning * Allows mobs which have defined Species to assign attributes based on these traits */ public interface INeedsPostUpdate { void updateAttributes(); }
282
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
INestingMob.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/INestingMob.java
package untamedwilds.entity; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.Block; public interface INestingMob { // When using this Interface, use a variable to keep track of the egg-laying state /** * Method to check whether the mob needs to deposit its eggs, and build a nest, if none is available */ boolean wantsToLayEggs(); /** * Method to set the egg-laying status * @param status the new boolean */ void setEggStatus(boolean status); /** * Assigns the Block instance which this entity will use as a nest, only blocks with an attached NestBlockEntity will be valid */ Block getNestType(); /** * Additional conditions to check whether a block is a valid nesting position or not, including conditions for it to be one * @param pos the BlockPos to be checked */ boolean isValidNestBlock(BlockPos pos); default boolean isEggLayer() { return true; } }
980
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ProjectileSpit.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ProjectileSpit.java
package untamedwilds.entity; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.ProjectileUtil; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import untamedwilds.init.ModEntity; import javax.annotation.Nullable; public class ProjectileSpit extends Projectile { private MobEffectInstance mobEffect; public <T extends Mob> ProjectileSpit(EntityType<? extends ProjectileSpit> p_37224_, Level p_37225_) { super(p_37224_, p_37225_); } public ProjectileSpit(Level p_37235_, ComplexMob p_37236_) { this(p_37235_, p_37236_, null); } public ProjectileSpit(Level p_37235_, ComplexMob p_37236_, @Nullable MobEffectInstance effect) { this(ModEntity.SPIT.get(), p_37235_); this.setOwner(p_37236_); this.mobEffect = effect; this.setPos(p_37236_.getX() - (double)(p_37236_.getBbWidth() + 1.0F) * 0.5D * (double) Mth.sin(p_37236_.yBodyRot * ((float)Math.PI / 180F)), p_37236_.getEyeY() - (double)0.1F, p_37236_.getZ() + (double)(p_37236_.getBbWidth() + 1.0F) * 0.5D * (double)Mth.cos(p_37236_.yBodyRot * ((float)Math.PI / 180F))); } public void tick() { super.tick(); Vec3 vec3 = this.getDeltaMovement(); HitResult hitresult = ProjectileUtil.getHitResult(this, this::canHitEntity); if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) this.onHit(hitresult); double d0 = this.getX() + vec3.x; double d1 = this.getY() + vec3.y; double d2 = this.getZ() + vec3.z; this.updateRotation(); if (this.level.getBlockStates(this.getBoundingBox()).noneMatch(BlockBehaviour.BlockStateBase::isAir)) { this.discard(); } else if (this.isInWaterOrBubble()) { this.discard(); } else { this.setDeltaMovement(vec3.scale(0.99F)); if (!this.isNoGravity()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, (double)-0.06F, 0.0D)); } this.setPos(d0, d1, d2); } } protected void onHitEntity(EntityHitResult p_37241_) { super.onHitEntity(p_37241_); if (this.getOwner() == null || !this.getOwner().getClass().equals(p_37241_.getEntity().getClass())) p_37241_.getEntity().hurt(DamageSource.indirectMobAttack(this, (LivingEntity)this.getOwner()).setProjectile(), 1); if (this.mobEffect != null && p_37241_.getEntity() instanceof LivingEntity living) living.addEffect(this.mobEffect); } protected void onHitBlock(BlockHitResult p_37239_) { super.onHitBlock(p_37239_); if (!this.level.isClientSide) { this.discard(); } } protected void defineSynchedData() { } public void recreateFromPacket(ClientboundAddEntityPacket p_150162_) { super.recreateFromPacket(p_150162_); double d0 = p_150162_.getXa(); double d1 = p_150162_.getYa(); double d2 = p_150162_.getZa(); for(int i = 0; i < 7; ++i) { double d3 = 0.4D + 0.1D * (double)i; this.level.addParticle(ParticleTypes.SPIT, this.getX(), this.getY(), this.getZ(), d0 * d3, d1, d2 * d3); } this.setDeltaMovement(d0, d1, d2); } }
3,979
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ISpecies.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ISpecies.java
package untamedwilds.entity; import net.minecraft.core.Holder; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceKey; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.level.biome.Biome; import untamedwilds.config.ConfigGamerules; import untamedwilds.util.SpeciesDataHolder; import java.util.ArrayList; import java.util.List; import java.util.Random; /** * Interface reserved for mobs which implement species, defined as an attached Enum * Species are visual variants of the original Entity, and should not have unique behaviors * Unlike ISkins, ISpecies need to match their species to breed, and may have unique Eggs and/or Spawn Items * Each Species defined as the attached Enum needs to have it's own .sciname defined */ public interface ISpecies { default int setSpeciesByBiome(Holder<Biome> biome, MobSpawnType reason) { if (ConfigGamerules.randomSpecies.get() || isArtificialMobSpawnType(reason)) { return ((Mob)this).getRandom().nextInt(ComplexMob.getEntityData(((Mob)this).getType()).getSpeciesData().size()); } List<Integer> validTypes = new ArrayList<>(); for (SpeciesDataHolder speciesDatum : ComplexMob.getEntityData(((Mob)this).getType()).getSpeciesData()) { for (List<SpeciesDataHolder.BiomeTestHolder> testList : speciesDatum.getBiomeCategories()) { List<Boolean> results = new ArrayList<>(); for (SpeciesDataHolder.BiomeTestHolder test : testList) { //UntamedWilds.LOGGER.info("Trying to spawn " + ((MobEntity)this).getType().getRegistryName().getPath() + " in " + biome.getRegistryName() + " returns " + test.isValidBiome(biomekey, biome)); if (!test.isValidBiome(biome, biome.value())) { break; } results.add(true); } if (results.size() == testList.size()) { for (int i=0; i < speciesDatum.getRarity(); i++) { validTypes.add(speciesDatum.getVariant()); } } } } if (validTypes.isEmpty()) { return 99; } else { return validTypes.get(new Random().nextInt(validTypes.size())); } } default String getRawSpeciesName(int i) { return ComplexMob.getEntityData(((ComplexMob)this).getType()).getSpeciesData().get(i).getName().toLowerCase(); } default String getSpeciesName(int i) { return new TranslatableComponent("entity.untamedwilds." + ((ComplexMob)this).getType().getRegistryName().getPath() + "_" + getRawSpeciesName(i)).getString(); } default String getSpeciesName() { return this instanceof ComplexMob ? getSpeciesName(((ComplexMob)this).getVariant()) : ""; } default boolean isArtificialMobSpawnType(MobSpawnType reason) { return reason == MobSpawnType.SPAWN_EGG || reason == MobSpawnType.BUCKET || reason == MobSpawnType.MOB_SUMMONED || reason == MobSpawnType.COMMAND || reason == MobSpawnType.SPAWNER; } }
3,192
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
INewSkins.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/INewSkins.java
package untamedwilds.entity; /** * Interface reserved for mobs which have the updated skin system implemented */ // TODO: Rework this Interface to mark UntamedWilds entities, rather than using ENTITY_DATA. Generalize functions to work based on this public interface INewSkins { }
285
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ComplexMob.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ComplexMob.java
package untamedwilds.entity; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.EntityDamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.ServerLevelAccessor; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import untamedwilds.block.blockentity.CritterBurrowBlockEntity; import untamedwilds.compat.CompatBridge; import untamedwilds.compat.CompatSereneSeasons; import untamedwilds.config.ConfigGamerules; import untamedwilds.config.ConfigMobControl; import untamedwilds.init.ModAdvancementTriggers; import untamedwilds.util.EntityDataHolder; import untamedwilds.util.EntityDataHolderClient; import untamedwilds.util.EntityDataListenerEvent; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import java.util.ArrayList; import java.util.HashMap; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public abstract class ComplexMob extends TamableAnimal { public static HashMap<String, HashMap<Integer, ArrayList<ResourceLocation>>> TEXTURES_COMMON = new HashMap<>(); public static HashMap<String, HashMap<Integer, ArrayList<ResourceLocation>>> TEXTURES_RARE = new HashMap<>(); private static final EntityDataAccessor<BlockPos> HOME_POS = SynchedEntityData.defineId(ComplexMob.class, EntityDataSerializers.BLOCK_POS); private static final EntityDataAccessor<Integer> VARIANT = SynchedEntityData.defineId(ComplexMob.class, EntityDataSerializers.INT); private static final EntityDataAccessor<Integer> SKIN = SynchedEntityData.defineId(ComplexMob.class, EntityDataSerializers.INT); private static final EntityDataAccessor<Float> SIZE = SynchedEntityData.defineId(ComplexMob.class, EntityDataSerializers.FLOAT); private static final EntityDataAccessor<Integer> GENDER = SynchedEntityData.defineId(ComplexMob.class, EntityDataSerializers.INT); // 0 - Male, 1 - Female private static final EntityDataAccessor<Boolean> IS_ANGRY = SynchedEntityData.defineId(ComplexMob.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor<Integer> COMMAND = SynchedEntityData.defineId(ComplexMob.class, EntityDataSerializers.INT); private static final EntityDataAccessor<Boolean> SLEEPING = SynchedEntityData.defineId(ComplexMob.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor<Boolean> SITTING = SynchedEntityData.defineId(ComplexMob.class, EntityDataSerializers.BOOLEAN); public HerdEntity herd = null; public float turn_speed = 1F; public int huntingCooldown; public int retaliationCooldown; public static HashMap<EntityType<?>, EntityDataHolder> ENTITY_DATA_HASH = new HashMap<>(); public static HashMap<EntityType<?>, EntityDataHolderClient> CLIENT_DATA_HASH = new HashMap<>(); public ComplexMob(EntityType<? extends ComplexMob> type, Level worldIn){ super(type, worldIn); this.moveControl = new MoveControl(this); } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(HOME_POS, BlockPos.ZERO); this.entityData.define(VARIANT, 0); this.entityData.define(SKIN, 0); this.entityData.define(SIZE, 1F); this.entityData.define(GENDER, 0); this.entityData.define(IS_ANGRY, false); this.entityData.define(COMMAND, 0); this.entityData.define(SLEEPING, false); this.entityData.define(SITTING, false); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.huntingCooldown > 0) this.huntingCooldown--; if (this.retaliationCooldown > 0) this.retaliationCooldown--; if (this.tickCount % 600 == 0 && this.wantsToBreed()) { this.setInLove(null); } } } /** * Wrapper method to access EntityDataHolder objects, contains safeguards against accessing data before its initialization * @param typeIn The EntityType to access in ENTITY_DATA_HASH, or initialize it if needed */ public static EntityDataHolder getEntityData(EntityType<?> typeIn) { if (!ENTITY_DATA_HASH.containsKey(typeIn)) { EntityDataListenerEvent.registerEntityData(typeIn); } return ENTITY_DATA_HASH.get(typeIn); } protected SoundEvent getAmbientSound() { return EntityUtils.getSound(this.getType(), this.getVariant(), "ambient"); } protected SoundEvent getHurtSound(@NotNull DamageSource source) { return EntityUtils.getSound(this.getType(), this.getVariant(), "hurt", SoundEvents.GENERIC_HURT); } protected SoundEvent getDeathSound() { return EntityUtils.getSound(this.getType(), this.getVariant(), "death", SoundEvents.GENERIC_DEATH); } protected SoundEvent getThreatSound() { return EntityUtils.getSound(this.getType(), this.getVariant(), "threat"); } public boolean checkSpawnRules(LevelAccessor worldIn, MobSpawnType spawnReasonIn) { return true; } // Why is a method called 'checkSpawnObstruction()' also checking for Water? @Override public boolean checkSpawnObstruction(LevelReader worldIn) { //return !p_21433_.containsAnyLiquid(this.getBoundingBox()) && p_21433_.isUnobstructed(this); return worldIn.isUnobstructed(this); } @Override public boolean canBeLeashed(Player player) { if (player.isCreative()) { return !this.isLeashed(); } return (!this.isLeashed() && this.isTame()); } @Override public boolean removeWhenFarAway(double p_21542_) { return false; } public void setSleeping(boolean sleeping){ this.entityData.set(SLEEPING, sleeping); } public boolean isSleeping(){ return (this.entityData.get(SLEEPING)); } public void setSitting(boolean sitting){ this.entityData.set(SITTING, sitting); } public boolean isSitting(){ return (this.entityData.get(SITTING)); } public boolean isNotMoving(){ return this.getDeltaMovement().x == 0 && this.getDeltaMovement().z == 0; } public boolean canBeTargeted() { return true; } public double getCurrentSpeed() { return Math.sqrt(this.getDeltaMovement().x * this.getDeltaMovement().x + this.getDeltaMovement().z * this.getDeltaMovement().z); } public int getAmbientSoundInterval() { //return Integer.MAX_VALUE; return 300; } protected int getExperienceReward(Player p_27590_) { int xp = Math.max(getEcoLevel(this) / 2, 1); return xp + this.level.random.nextInt(xp); } public int getVariant(){ return (this.entityData.get(VARIANT)); } public void setVariant(int variant){ this.entityData.set(VARIANT, variant); } public int getSkin(){ return (this.entityData.get(SKIN)); } public void setSkin(int skin){ this.entityData.set(SKIN, skin); } public <T extends ComplexMob> void chooseSkinForSpecies(T entityIn, boolean allowRares) { if (entityIn.getType().getRegistryName() != null && this instanceof INewSkins && !this.level.isClientSide) { String name = entityIn.getType().getRegistryName().getPath(); if (!TEXTURES_COMMON.get(name).isEmpty()) { boolean isRare = allowRares && TEXTURES_RARE.get(name).containsKey(this.getVariant()) && this.random.nextFloat() < ConfigGamerules.rareSkinChance.get(); int skin = this.random.nextInt(isRare ? TEXTURES_RARE.get(name).get(this.getVariant()).size() : TEXTURES_COMMON.get(name).get(this.getVariant()).size()) + (isRare ? 100 : 0); this.setSkin(skin); } } } public float getModelScale() { return getEntityData(this.getType()).getScale(this.getVariant()); } public float getMobSize(){ return (this.entityData.get(SIZE)); } public void setMobSize(float size){ this.entityData.set(SIZE, size); } public void setRandomMobSize(){ this.entityData.set(SIZE, this.getModelScale() + ((float)this.random.nextGaussian() * 0.1F)); } public void setGender(int gender){ this.entityData.set(GENDER, gender); } public int getGender(){ return (this.entityData.get(GENDER)); } public boolean isMale() { return this.getGender() == 0; } public String getGenderString() { return this.isMale() ? "male" : "female"; } public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get()) { if (CompatBridge.SereneSeasons) { return CompatSereneSeasons.isCurrentSeason(this.level, this.getBreedingSeason()); } return true; //return this.isInLove(); } return false; } @SuppressWarnings("unchecked") // Don't use this outside ComplexMobs public <T extends ComplexMob> void breed() { int bound = 1 + (this.getOffspring() > 0 ? this.random.nextInt(this.getOffspring() + 1) : 0); for (int i = 0; i < bound; i++) { T child = (T) this.getBreedOffspring((ServerLevel) this.level, this); if (child != null) { child.setVariant(this.getVariant()); child.setAge(this.getAdulthoodTime() * -1); child.setGender(this.random.nextInt(2)); child.setRandomMobSize(); child.setBaby(true); child.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); if (this.getOwner() != null) child.tame((Player) this.getOwner()); if (this instanceof INeedsPostUpdate) { ((INeedsPostUpdate) child).updateAttributes(); } if (TEXTURES_COMMON.containsKey(child.getType().getRegistryName().getPath())) { chooseSkinForSpecies(child, true); } //((ServerLevel)this.level).addFreshEntityWithPassengers(child); this.level.addFreshEntity(child); this.level.broadcastEntityEvent(this, (byte)18); } } } protected <T extends ComplexMob> T create_offspring(T entity) { entity.setGender(this.random.nextInt(2)); entity.setRandomMobSize(); entity.setVariant(this.getVariant()); entity.chooseSkinForSpecies(this, true); if (entity instanceof INeedsPostUpdate) { ((INeedsPostUpdate) entity).updateAttributes(); } return entity; } public String getBreedingSeason() { return getEntityData(this.getType()).getBreedingSeason(this.getVariant()); } // Adulthood time is twice the Growing time, and only used for mobs that do not lay eggs public int getAdulthoodTime() { return getEntityData(this.getType()).getGrowingTime(this.getVariant()) * ConfigGamerules.cycleLength.get() * 2; } public int getPregnancyTime() { return getEntityData(this.getType()).getGrowingTime(this.getVariant()) * ConfigGamerules.cycleLength.get(); } public int getOffspring() { return getEntityData(this.getType()).getOffspring(this.getVariant()); } public boolean isFood(ItemStack stack) { if (getEntityData(this.getType()).getFavouriteFood(this.getVariant()).getItem().equals(Blocks.AIR.asItem())) return false; return stack.getItem().equals(getEntityData(this.getType()).getFavouriteFood(this.getVariant()).getItem()); } public boolean canTakeItem(ItemStack stack) { return false; } private boolean isBlinking() { return this.tickCount % 60 > 53; } public boolean shouldRenderEyes() { return !this.isSleeping() && !this.dead && !this.isBlinking() && this.hurtTime == 0; } public boolean canMove() { return !this.isSitting() && !this.isSleeping() && !this.isVehicle(); } public void setHome(BlockPos position) { this.entityData.set(HOME_POS, position); } public BlockPos getHome() { return this.entityData.get(HOME_POS); } public Vec3 getHomeAsVec() { BlockPos home = this.getHome(); return new Vec3(home.getX(), home.getY(), home.getZ()); } public void setAge(int age) { int i = this.age; super.setAge(age); this.age = age; if (!this.isMale() && !(this instanceof INestingMob nestingMob && nestingMob.isEggLayer()) && !ConfigGamerules.easyBreeding.get()) { if (i > 0 && age <= 0) { this.breed(); } } } public ResourceLocation getTexture() { return EntityUtils.getSkinFromEntity(this); } // Returns the ecological level of an entity. Values are dynamically calculated based on current HP, Attack and Herd size (if any) public static int getEcoLevel(LivingEntity entity) { if (entity instanceof Player) { return (int) (4 + (entity.getHealth() / 6)); } int attack = (int) Math.max(entity.getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE) ? entity.getAttribute(Attributes.ATTACK_DAMAGE).getValue() : 1, 4); if (entity instanceof ComplexMob && ((ComplexMob) entity).herd != null) { return (int) (Math.sqrt(entity.getHealth() * attack) / 2.5F) + ((ComplexMob) entity).herd.creatureList.size(); } return (int) (Math.sqrt(entity.getHealth() * attack) / 2.5F); } protected void performRetaliation(DamageSource damageSource, float health, float damage, boolean needsActiveTarget) { if (needsActiveTarget && this.getTarget() != damageSource.getDirectEntity()) return; if (this.retaliationCooldown == 0 && !this.isNoAi() && this.getTarget() != null && damage < health && !damageSource.isProjectile() && damageSource.getDirectEntity() instanceof LivingEntity && !(damageSource.getDirectEntity() instanceof Player) && !(damageSource.getDirectEntity() instanceof TamableAnimal tamable && tamable.getOwner() != null)) { if ((damageSource instanceof EntityDamageSource && ((EntityDamageSource)damageSource).isThorns()) && this.hasLineOfSight(damageSource.getDirectEntity())) { damageSource.getDirectEntity().hurt(DamageSource.thorns(this), (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE)); this.retaliationCooldown = 10; } } } protected void setAngry(boolean isAngry) { this.entityData.set(IS_ANGRY, isAngry); } public boolean isAngry() { return (this.entityData.get(IS_ANGRY)); } // Commands: // 0 - Wander: The mob wanders around naturally // 1 - Follow: The mob will follow its owner, occasionally teleporting // 2 - Sit: The mob will sit in place // 3 - Guard: The mob will sit in place and attack nearby mobs (NIY) public void setCommandInt(int command) { this.entityData.set(COMMAND, command % 3); } public int getCommandInt() { return (this.entityData.get(COMMAND)); } public boolean shouldDespawn() { return this instanceof ISpecies && this.getHome() != BlockPos.ZERO; } @Override public void checkDespawn() { super.checkDespawn(); if (this.shouldDespawn()) { if (!this.level.hasNearbyAlivePlayer(this.getX(), this.getY(), this.getZ(), ConfigMobControl.critterSpawnRange.get())) { if (this instanceof ISpecies && this.getHome() != BlockPos.ZERO) { BlockEntity burrow = this.level.getBlockEntity(this.getHome()); if (burrow instanceof CritterBurrowBlockEntity) { ((CritterBurrowBlockEntity)burrow).tryEnterBurrow(this); burrow.setChanged(); } } } } } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); if (this.getHome() != BlockPos.ZERO) { compound.putInt("HomePosX", this.getHome().getX()); compound.putInt("HomePosY", this.getHome().getY()); compound.putInt("HomePosZ", this.getHome().getZ()); } if (this.isTame()) { compound.putInt("Command", this.getCommandInt()); } compound.putInt("Variant", this.getVariant()); compound.putInt("Skin", this.getSkin()); compound.putFloat("Size", this.getMobSize()); compound.putInt("Gender", this.getGender()); compound.putBoolean("isAngry", this.isAngry()); compound.putInt("PeacefulTicks", this.huntingCooldown); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); if (compound.contains("HomePosX")) { int i = compound.getInt("HomePosX"); int j = compound.getInt("HomePosY"); int k = compound.getInt("HomePosZ"); this.setHome(new BlockPos(i, j, k)); } if (compound.contains("OwnerUUID")) { this.setCommandInt(compound.getInt("Command")); } this.setVariant(EntityUtils.getClampedNumberOfSpecies(compound.getInt("Variant"), this.getType())); //this.setVariant(compound.getInt("Variant")); this.setSkin(compound.getInt("Skin")); this.setMobSize(compound.getFloat("Size")); this.setGender(compound.getInt("Gender")); this.setAngry(compound.getBoolean("isAngry")); this.huntingCooldown = compound.getInt("PeacefulTicks"); } @Nullable public SpawnGroupData finalizeSpawn(ServerLevelAccessor worldIn, DifficultyInstance difficultyIn, MobSpawnType reason, @Nullable SpawnGroupData spawnDataIn, @Nullable CompoundTag dataTag) { if (reason != MobSpawnType.DISPENSER && reason != MobSpawnType.BUCKET && reason != MobSpawnType.BREEDING) { if (this instanceof ISpecies) { Holder<Biome> optional = worldIn.getBiome(new BlockPos(this.position())); int i = ((ISpecies)this).setSpeciesByBiome(optional, reason); this.setVariant(i); if (i == 99) { this.remove(RemovalReason.DISCARDED); return null; } } this.setGender(this.random.nextInt(2)); this.setRandomMobSize(); if (TEXTURES_COMMON.containsKey(this.getType().getRegistryName().getPath())) { chooseSkinForSpecies(this, ConfigGamerules.wildRareSkins.get()); } if (this instanceof INeedsPostUpdate) { ((INeedsPostUpdate) this).updateAttributes(); } this.setAge(0); } if (this instanceof IPackEntity) { IPackEntity.initPack(this); } return spawnDataIn; } public InteractionResult mobInteract(Player player, InteractionHand hand) { if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { if (!CompatBridge.Patchouli) { ModAdvancementTriggers.NO_PATCHOULI_LOADED.trigger((ServerPlayer) player); } ItemStack itemstack = player.getItemInHand(hand); // Highlight mobs in the same pack if Player is in Creative mode if (player.isCreative() && itemstack.isEmpty() && this instanceof IPackEntity && this.herd != null) { for (int i = 0; i < this.herd.creatureList.size(); ++i) { ComplexMob creature = this.herd.creatureList.get(i); creature.addEffect(new MobEffectInstance(MobEffects.GLOWING, 80, 0)); } } // Command handler for tamed mobs, includes Food/Potion consumption if (this.isTame() && this.getOwner() == player) { if (itemstack.isEmpty()) { this.setCommandInt(this.getCommandInt() + 1); player.sendMessage(new TranslatableComponent("entity.untamedwilds.command." + this.getCommandInt()), Util.NIL_UUID); if (this.getCommandInt() > 1) { this.getNavigation().stop(); this.setSitting(true); } else if (this.getCommandInt() <= 1 && this.isSitting()) { this.setSitting(false); } } else { EntityUtils.consumeItemStack(this, itemstack); } } return super.mobInteract(player, hand); } return InteractionResult.PASS; } }
21,934
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
ComplexMobAmphibious.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ComplexMobAmphibious.java
package untamedwilds.entity; import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.ai.navigation.PathNavigation; import net.minecraft.world.entity.ai.navigation.WaterBoundPathNavigation; import net.minecraft.world.level.Level; import net.minecraft.world.level.pathfinder.AmphibiousNodeEvaluator; import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.level.pathfinder.PathFinder; import untamedwilds.entity.ai.control.look.SmartSwimmerLookControl; import untamedwilds.entity.ai.control.movement.SmartSwimmingMoveControl; public abstract class ComplexMobAmphibious extends ComplexMobTerrestrial { protected boolean isAmphibious; public ComplexMobAmphibious(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.moveControl = new SmartSwimmingMoveControl(this, 40, 5, 0.25F, 0.3F, true); this.lookControl = new SmartSwimmerLookControl(this, 20); this.setPathfindingMalus(BlockPathTypes.WATER, 0.0F); this.maxUpStep = 1.0F; } protected PathNavigation createNavigation(Level worldIn) { return new ComplexMobAmphibious.AmphibiousPathNavigation(this, worldIn); } public boolean wantsToBeOnLand() { return true; } public boolean wantsToBeInWater() { return false; } public float getWaterSlowDown() { return this.isOnGround() ? 0.8F : 0.9F; } @Override public boolean canBreatheUnderwater() { return true; } protected SoundEvent getSwimSound() { return SoundEvents.AXOLOTL_SWIM; } static class AmphibiousPathNavigation extends WaterBoundPathNavigation { private final ComplexMobAmphibious entityIn; AmphibiousPathNavigation(ComplexMobAmphibious entityIn, Level worldIn) { super(entityIn, worldIn); this.entityIn = entityIn; } protected boolean canUpdatePath() { return true; } protected PathFinder createPathFinder(int p_149222_) { this.nodeEvaluator = new AmphibiousNodeEvaluator(false); return new PathFinder(this.nodeEvaluator, p_149222_); } public boolean isStableDestination(BlockPos destinationIn) { if (this.entityIn.wantsToBeInWater()) { return !this.level.getBlockState(destinationIn).isSolidRender(this.level, destinationIn) && this.level.getFluidState(destinationIn) != null; } else if (this.entityIn.wantsToBeOnLand()) { BlockPos blockpos = destinationIn.below(); return this.level.getBlockState(blockpos).isSolidRender(this.level, blockpos); } return !this.level.getBlockState(destinationIn.below()).isAir(); } } }
2,914
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntitySoftshellTurtle.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/reptile/EntitySoftshellTurtle.java
package untamedwilds.entity.reptile; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import oshi.util.tuples.Pair; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.control.look.SmartSwimmerLookControl; import untamedwilds.entity.ai.control.movement.SmartSwimmingMoveControl; import untamedwilds.entity.ai.target.HuntMobTarget; import untamedwilds.init.ModBlock; import untamedwilds.init.ModItems; import untamedwilds.init.ModTags; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntitySoftshellTurtle extends ComplexMobAmphibious implements ISpecies, INewSkins, INestingMob { private static final EntityDataAccessor<Boolean> HAS_EGG = SynchedEntityData.defineId(EntitySoftshellTurtle.class, EntityDataSerializers.BOOLEAN); public boolean hasExtendedNeck; public int extendNeckProgress; public Pair<Float, Float> head_movement; private float neck_val = 0; private float head_val = 0; public EntitySoftshellTurtle(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.moveControl = new SmartSwimmingMoveControl(this, 60, 10, 0.6F, 0.25F, true); this.lookControl = new SmartSwimmerLookControl(this, 20); this.head_movement = new Pair<>(0F, 0F); } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(HAS_EGG, false); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 1.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.7D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 6.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0D) .add(Attributes.ARMOR, 2D); } public void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 1D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 0.7D)); this.goalSelector.addGoal(2, new SmartAvoidGoal<>(this, LivingEntity.class, 16, 1D, 1.1D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(3, new LayEggsOnNestGoal(this)); this.goalSelector.addGoal(3, new AmphibiousTransition(this, 1D)); this.goalSelector.addGoal(4, new AmphibiousRandomSwimGoal(this, 0.7, 40)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); this.targetSelector.addGoal(3, new HuntMobTarget<>(this, LivingEntity.class, true, 30, false, input -> getEcoLevel(input) < getEcoLevel(this))); } public boolean wantsToBeOnLand() { return this.level.getDayTime() > 4500 && this.level.getDayTime() < 7500; } public boolean wantsToBeInWater() { return !(this.level.getDayTime() > 4500 && this.level.getDayTime() < 7500); } public boolean isPushedByFluid() { return false; } public void die(DamageSource cause) { if (cause == DamageSource.ANVIL && !this.isBaby()) { // Advancement Trigger: "Unethical Soup" ItemEntity entityitem = this.spawnAtLocation(new ItemStack(ModItems.FOOD_TURTLE_SOUP.get()), 0.2F); if (entityitem != null) { entityitem.getItem().setCount(1); } } super.die(cause); } public void tick() { super.tick(); if (this.level.isClientSide && this.isInWater() && this.getDeltaMovement().lengthSqr() > 0.03D) { Vec3 vec3 = this.getViewVector(0.0F); float f = Mth.cos(this.getYRot() * ((float)Math.PI / 180F)) * 0.3F; float f1 = Mth.sin(this.getYRot() * ((float)Math.PI / 180F)) * 0.3F; float f2 = 1.2F - this.random.nextFloat() * 0.7F; for(int i = 0; i < 2; ++i) { this.level.addParticle(ParticleTypes.DOLPHIN, this.getX() - vec3.x * (double)f2 + (double)f, this.getY() - vec3.y, this.getZ() - vec3.z * (double)f2 + (double)f1, 0.0D, 0.0D, 0.0D); this.level.addParticle(ParticleTypes.DOLPHIN, this.getX() - vec3.x * (double)f2 - (double)f, this.getY() - vec3.y, this.getZ() - vec3.z * (double)f2 - (double)f1, 0.0D, 0.0D, 0.0D); } } if (this.tickCount % 1000 == 0) { this.hasExtendedNeck = this.random.nextBoolean(); } if (this.tickCount % 120 < 11) { if (this.tickCount % 120 == 1) { neck_val = (float) (0.8F - this.random.nextDouble() * 1.6F); head_val = (float) (0.4F - this.random.nextDouble() * 0.8F); } this.head_movement = new Pair<>(Mth.lerp(0.1F, head_movement.getA(), neck_val), Mth.lerp(0.1F, head_movement.getB(), head_val)); } } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } if (this.isInWater() && this.getNavigation().isDone()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.003D, 0.0D)); } } else { if ((!this.isInWater() || this.hasExtendedNeck) && this.extendNeckProgress < 100) { this.extendNeckProgress++; } else if ((this.isInWater() || !this.hasExtendedNeck) && this.extendNeckProgress > 0) { this.extendNeckProgress--; } } } /* Breeding conditions for the softshell_turtle are: * A nearby softshell_turtle of the opposite gender and the same species */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntitySoftshellTurtle> list = this.level.getEntitiesOfClass(EntitySoftshellTurtle.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); return list.size() >= 1; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_softshell_turtle", this.getOffspring()); return null; } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (itemstack.isEmpty() && this.isAlive()) { EntityUtils.turnEntityIntoItem(this, "spawn_softshell_turtle"); return InteractionResult.sidedSuccess(this.level.isClientSide); } return super.mobInteract(player, hand); } protected void playStepSound(BlockPos pos, BlockState blockIn) { SoundEvent soundevent = this.isBaby() ? SoundEvents.TURTLE_SHAMBLE_BABY : SoundEvents.TURTLE_SHAMBLE; this.playSound(soundevent, 0.15F, 1.0F); } @Override public boolean wantsToLayEggs() { return this.entityData.get(HAS_EGG); } @Override public void setEggStatus(boolean status) { this.entityData.set(HAS_EGG, status); } @Override public Block getNestType() { return ModBlock.NEST_REPTILE.get(); } @Override public boolean isValidNestBlock(BlockPos pos) { return this.level.isEmptyBlock(pos) && this.level.getBlockState(pos.below()).is(ModTags.ModBlockTags.VALID_REPTILE_NEST) && this.getNestType().defaultBlockState().canSurvive(this.level, pos); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("has_egg", this.wantsToLayEggs()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setEggStatus(compound.getBoolean("has_egg")); } }
9,335
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityMonitor.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/reptile/EntityMonitor.java
package untamedwilds.entity.reptile; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.BlockTags; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import oshi.util.tuples.Pair; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.control.look.SmartSwimmerLookControl; import untamedwilds.entity.ai.control.movement.SmartSwimmingMoveControl; import untamedwilds.entity.ai.target.HuntMobTarget; import untamedwilds.init.ModBlock; import untamedwilds.init.ModTags; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityMonitor extends ComplexMobAmphibious implements ISpecies, INeedsPostUpdate, INewSkins, INestingMob { private static final EntityDataAccessor<Boolean> HAS_EGG = SynchedEntityData.defineId(EntityMonitor.class, EntityDataSerializers.BOOLEAN); public static Animation IDLE_TONGUE; public static Animation ATTACK_THRASH; public int swimProgress; public float offset; public Pair<Float, Float> head_movement; private float neck_val = 0; private float head_val = 0; public EntityMonitor(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.moveControl = new SmartSwimmingMoveControl(this, 40, 5, 0.25F, 0.3F, true); this.lookControl = new SmartSwimmerLookControl(this, 20); IDLE_TONGUE = Animation.create(20); ATTACK_THRASH = Animation.create(30); this.head_movement = new Pair<>(0F, 0F); this.ticksToSit = 20; } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(HAS_EGG, false); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 4.0D) .add(Attributes.ATTACK_KNOCKBACK, 0.1D) .add(Attributes.MOVEMENT_SPEED, 0.7D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 10.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0.2D); } public void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 1.4D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 0.7D)); this.goalSelector.addGoal(2, new SmartAvoidGoal<>(this, LivingEntity.class, (float)this.getAttributeValue(Attributes.FOLLOW_RANGE), 1D, 1.1D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(3, new SmartWanderGoal(this, 1.0D, true)); this.goalSelector.addGoal(3, new LayEggsOnNestGoal(this)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); this.targetSelector.addGoal(3, new HuntMobTarget<>(this, LivingEntity.class, true, false, input -> getEcoLevel(input) < getEcoLevel(this))); } public float getWalkTargetValue(BlockPos p_149140_, LevelReader p_149141_) { return 0.0F; } public boolean wantsToBeOnLand() { return true; } public boolean wantsToBeInWater() { return false; } public boolean isPushedByFluid() { return false; } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.isInWater()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.003D, 0.0D)); if (!this.isNotMoving() && this.random.nextInt(5) == 0 && this.getDeltaMovement().horizontalDistance() > 0.08) { Vec3 testpos = this.position().add(Math.cos(Math.toRadians(this.getYRot()+ 90)) * -0.8, 0, Math.sin(Math.toRadians(this.getYRot() + 90)) * -0.8); BlockPos testblockpos = new BlockPos(testpos); if (level.getBlockState(new BlockPos(testblockpos.below())).is(BlockTags.MINEABLE_WITH_SHOVEL)) ((ServerLevel)this.level).sendParticles(new BlockParticleOption(ParticleTypes.FALLING_DUST, this.level.getBlockState(testblockpos.below())), testpos.x, testpos.y + 0.2, testpos.z, 2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, 0); else ((ServerLevel)this.level).sendParticles(ParticleTypes.UNDERWATER, testpos.x, testpos.y + 0.2, testpos.z, 2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, 0); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } if (this.getAnimation() == NO_ANIMATION && this.getTarget() == null && !this.isSleeping()) { int i = this.random.nextInt(3000); if (i <= 10 && !this.isInWater()) { this.getNavigation().stop(); this.setSitting(true); } else if ((i == 11 || this.isInWater()) && this.isSitting()) { this.setSitting(false); } else if (i > 2900) { if (this.isVehicle() && this.getFirstPassenger() != null) { this.setAnimation(ATTACK_THRASH); doHurtTarget(this.getFirstPassenger()); } else { this.setAnimation(IDLE_TONGUE); } } } } else { if (Math.abs(this.getYRot() - this.yRotO) > 0.005) { this.offset = Mth.rotLerp(0.05F, this.offset, (this.getYRot() - this.yRotO)); } if (this.isInWater() && !this.isNotMoving()) { if (this.swimProgress < 20) this.swimProgress++; } else if ((!this.isInWater() || this.isNotMoving()) && this.swimProgress > 0) { this.swimProgress--; } if (this.tickCount % 120 < 11) { if (this.tickCount % 120 == 1) { neck_val = (float) (0.8F - this.random.nextDouble() * 1.6F); head_val = (float) (0.4F - this.random.nextDouble() * 0.8F); } this.head_movement = new Pair<>(Mth.lerp(0.1F, head_movement.getA(), neck_val), Mth.lerp(0.1F, head_movement.getB(), head_val)); } } } /* Breeding conditions for the giant salamander are: * A nearby giant salamander of the opposite gender and the same species */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityMonitor> list = this.level.getEntitiesOfClass(EntityMonitor.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } } return false; } public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { this.setAnimation(ATTACK_THRASH); this.setAnimationTick(0); if (entityIn instanceof LivingEntity) { ((LivingEntity)entityIn).addEffect(new MobEffectInstance(MobEffects.POISON, 40, 0)); if (!this.isVehicle() && entityIn.getBbWidth() * entityIn.getBbHeight() < 0.4F && !(entityIn instanceof TamableAnimal && ((TamableAnimal) entityIn).isTame())) { entityIn.startRiding(this); ((LivingEntity) entityIn).setHealth(10); } } } return flag; } public double getPassengersRidingOffset() { return 0D; } @Override public void positionRider(Entity p_20312_) { //super.positionRider(p_20312_); this.positionPreyInJaw(p_20312_, Entity::setPos); } private void positionPreyInJaw(Entity p_19957_, Entity.MoveFunction p_19958_) { if (this.hasPassenger(p_19957_)) { int rev = this.getAnimationTick() % 12 >= 6 ? -1 : 1; int factor = rev * (this.getAnimationTick() % 12); double d0 = this.getY() + this.getPassengersRidingOffset() + p_19957_.getMyRidingOffset(); p_19958_.accept(p_19957_, this.getX() + Math.cos(Math.toRadians(this.getYRot() + 90 + (factor * 4))) * 1, d0, this.getZ() + Math.sin(Math.toRadians(this.getYRot() + 90 + (factor * 4))) * 1); } } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (itemstack.isEmpty() && this.isAlive() && hand.equals(InteractionHand.MAIN_HAND)) { this.setAnimation(ATTACK_THRASH); return InteractionResult.sidedSuccess(this.level.isClientSide); } return super.mobInteract(player, hand); } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_monitor", this.getOffspring()); return null; } protected void playStepSound(BlockPos pos, BlockState blockIn) { SoundEvent soundevent = this.isBaby() ? SoundEvents.TURTLE_SHAMBLE_BABY : SoundEvents.TURTLE_SHAMBLE; this.playSound(soundevent, 0.15F, 1.0F); } public boolean hurt(DamageSource damageSource, float amount) { // Retaliate I: Mob will strike back when attacked by its current target performRetaliation(damageSource, this.getHealth(), amount, true); return super.hurt(damageSource, amount); } public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, IDLE_TONGUE, ATTACK_THRASH}; } @Override public void updateAttributes() { this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getAttack()); this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getHealth()); this.setHealth(this.getMaxHealth()); } @Override public boolean wantsToLayEggs() { return this.entityData.get(HAS_EGG); } @Override public void setEggStatus(boolean status) { this.entityData.set(HAS_EGG, status); } @Override public Block getNestType() { return ModBlock.NEST_REPTILE.get(); } @Override public boolean isValidNestBlock(BlockPos pos) { return this.level.isEmptyBlock(pos) && this.level.getBlockState(pos.below()).is(ModTags.ModBlockTags.VALID_REPTILE_NEST) && this.getNestType().defaultBlockState().canSurvive(this.level, pos); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("has_egg", this.wantsToLayEggs()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setEggStatus(compound.getBoolean("has_egg")); } }
12,704
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityAnaconda.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/reptile/EntityAnaconda.java
package untamedwilds.entity.reptile; import com.mojang.math.Vector3d; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.control.SmoothSwimmingLookControl; import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.phys.Vec3; import net.minecraftforge.entity.PartEntity; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.control.movement.SmartSwimmingMoveControl; import untamedwilds.entity.ai.target.HuntMobTarget; import untamedwilds.init.ModBlock; import untamedwilds.init.ModEntity; import untamedwilds.init.ModItems; import untamedwilds.init.ModTags; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityAnaconda extends ComplexMobAmphibious implements ISpecies, INeedsPostUpdate, INewSkins, INestingMob { private static final EntityDataAccessor<Boolean> HAS_EGG = SynchedEntityData.defineId(EntityAnaconda.class, EntityDataSerializers.BOOLEAN); public final int length; public final EntityAnacondaPart[] anacondaParts; public final float[] buffer = new float[3]; public int ringBufferIndex = -1; public final double[][] ringBuffer = new double[64][3]; public EntityAnaconda(EntityType<? extends ComplexMobTerrestrial> type, Level worldIn) { super(type, worldIn); this.setPathfindingMalus(BlockPathTypes.WATER, 0.0F); this.moveControl = new SmartSwimmingMoveControl(this, 20, 5, 0.3F, 0.4F, true); this.lookControl = new SmoothSwimmingLookControl(this, 10); this.ticksToSit = 40; this.length = getMultiparts(); this.anacondaParts = new EntityAnacondaPart[this.length]; for (int i = 0; i < this.length; i++) { this.anacondaParts[i] = new EntityAnacondaPart(this, this.getBbWidth(), this.getBbHeight()); } } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(HAS_EGG, false); } private void setPartPosition(EntityAnacondaPart part, double offsetX, double offsetY, double offsetZ) { part.setPos(this.getX() + offsetX * part.scale, this.getY() + offsetY * part.scale, this.getZ() + offsetZ * part.scale); } @Override public boolean isMultipartEntity() { return true; } @Override public net.minecraftforge.entity.PartEntity<?>[] getParts() { return this.anacondaParts; } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 3.0D) .add(Attributes.ATTACK_KNOCKBACK, 0.6D) .add(Attributes.MOVEMENT_SPEED, 0.6D) .add(Attributes.FOLLOW_RANGE, 12.0D) .add(Attributes.MAX_HEALTH, 30.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0.8D) .add(Attributes.ARMOR, 4D); } public void registerGoals() { this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.3D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(3, new AmphibiousTransition(this, 1D)); this.goalSelector.addGoal(3, new LayEggsOnNestGoal(this)); this.goalSelector.addGoal(4, new AmphibiousRandomSwimGoal(this, 0.7, 400)); this.goalSelector.addGoal(4, new SmartWanderGoal(this, 0.7, false) { public boolean canUse() { if (this.creature.huntingCooldown != 0) return false; return super.canUse(); } }); this.targetSelector.addGoal(3, new HurtByTargetGoal(this)); this.targetSelector.addGoal(3, new HuntMobTarget<>(this, LivingEntity.class, true, 30, false, input -> getEcoLevel(input) < getEcoLevel(this))); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.tickCount % 1000 == 0) { if (this.random.nextInt(40) == 0) { this.spawnAtLocation(new ItemStack(ModItems.MATERIAL_SNAKE_SKIN.get()), 0.2F); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } if (this.getAnimation() == NO_ANIMATION && this.getTarget() == null && !this.isSleeping()) { int i = this.random.nextInt(3000); if (i <= 10 && !this.isInWater() && this.isNotMoving() && this.canMove()) { this.getNavigation().stop(); this.setSitting(true); } if ((i == 11 || this.isInWater() || this.isActive()) && this.isSitting()) { this.setSitting(false); } } if (this.isInWater()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.006D, 0.0D)); } this.setAngry(this.getTarget() != null); } if (!this.isNoAi() && !this.isBaby()) { if (this.canMove()) { if (this.ringBufferIndex < 0) { for (int i = 0; i < this.ringBuffer.length; ++i) { this.ringBuffer[i][0] = this.getYRot() ; this.ringBuffer[i][1] = this.getY(); } } this.ringBufferIndex++; if (this.ringBufferIndex == this.ringBuffer.length) { this.ringBufferIndex = 0; } this.ringBuffer[this.ringBufferIndex][0] = this.getYRot() ; this.ringBuffer[ringBufferIndex][1] = this.getY(); Vector3d[] avector3d = new Vector3d[this.anacondaParts.length]; for (int j = 0; j < this.anacondaParts.length; ++j) { this.anacondaParts[j].collideWithNearbyEntities(); avector3d[j] = new Vector3d(this.anacondaParts[j].getX(), this.anacondaParts[j].getY(), this.anacondaParts[j].getZ()); } float f15 = (float) (this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F * ((float) Math.PI / 180F); float f16 = Mth.cos(f15); float yaw = this.getYRot() * ((float) Math.PI / 180F); float pitch = this.getXRot() * ((float) Math.PI / 180F); float f3 = Mth.sin(yaw) * (1 - Math.abs(this.getXRot() / 90F)); float f18 = Mth.cos(yaw) * (1 - Math.abs(this.getXRot() / 90F)); double[] adouble = this.getMovementOffsets(5, 1.0F); for (int k = 0; k < getMultiparts(); ++k) { EntityAnacondaPart anaconda_part = this.anacondaParts[k]; double[] adouble1 = this.getMovementOffsets(5 + k * 2, 1.0F); float f7 = yaw + (float) Mth.wrapDegrees(adouble1[0] - adouble[0]) * ((float) Math.PI / 180F); float f20 = Mth.sin(f7) * (1 - Math.abs(this.getXRot() / 90F)); float f21 = Mth.cos(f7) * (1 - Math.abs(this.getXRot() / 90F)); float f23 = k == 0 ? (float) (k + 1) : (k + 1) * -1; float value = pitch * (k); this.setPartPosition(anaconda_part, -(f3 * 0.5F + f20 * f23) * f16, value, (f18 * 0.5F + f21 * f23) * f16); this.anacondaParts[k].xo = avector3d[k].x; this.anacondaParts[k].yo = avector3d[k].y; this.anacondaParts[k].zo = avector3d[k].z; this.anacondaParts[k].xOld = avector3d[k].x; this.anacondaParts[k].yOld = avector3d[k].y; this.anacondaParts[k].zOld = avector3d[k].z; } } else { for (int k = 0; k < getMultiparts(); ++k) { EntityAnacondaPart anaconda_part = this.anacondaParts[k]; this.setPartPosition(anaconda_part, 0, 0, 0); this.anacondaParts[k].xo = this.getX(); this.anacondaParts[k].yo = this.getY(); this.anacondaParts[k].zo = this.getZ(); this.anacondaParts[k].xOld = this.getX(); this.anacondaParts[k].yOld = this.getY(); this.anacondaParts[k].zOld = this.getZ(); } } } } public double[] getMovementOffsets(int p_70974_1_, float partialTicks) { if (this.isDeadOrDying()) { partialTicks = 0.0F; } partialTicks = 1.0F - partialTicks; int i = this.ringBufferIndex - p_70974_1_ & 63; int j = this.ringBufferIndex - p_70974_1_ - 1 & 63; double[] adouble = new double[3]; double d0 = this.ringBuffer[i][0]; double d1 = this.ringBuffer[j][0] - d0; adouble[0] = d0 + d1 * (double) partialTicks; d0 = this.ringBuffer[i][1]; d1 = this.ringBuffer[j][1] - d0; adouble[1] = d0 + d1 * (double) partialTicks; adouble[2] = Mth.lerp(partialTicks, this.ringBuffer[i][2], this.ringBuffer[j][2]); return adouble; } /* Breeding conditions for the Snake are: * A nearby Snake of the opposite gender and the same species */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityAnaconda> list = this.level.getEntitiesOfClass(EntityAnaconda.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); return list.size() >= 1; } } return false; } protected void playStepSound(BlockPos pos, BlockState blockIn) { } protected SoundEvent getAmbientSound() { if (this.isAngry()) { return super.getAmbientSound(); } return null; } @Nullable @Override public EntityAnaconda getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { if (!this.isEggLayer()) { return create_offspring(new EntityAnaconda(ModEntity.ANACONDA.get(), this.level)); //EntityUtils.dropEggs(this, "egg_large_snake_" + getRawSpeciesName(this.getVariant()).toLowerCase(), 4); } return null; } public boolean doHurtTarget(Entity entityIn) { float f = (float)this.getAttribute(Attributes.ATTACK_DAMAGE).getValue(); boolean flag = entityIn.hurt(DamageSource.mobAttack(this), f); if (flag) { if (this.huntingCooldown == 0 && entityIn instanceof LivingEntity && !(entityIn instanceof Player) && entityIn.getBbWidth() * entityIn.getBbHeight() < 1.2F && (entityIn instanceof TamableAnimal && !((TamableAnimal) entityIn).isTame())) { this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.BEEHIVE_ENTER, SoundSource.BLOCKS, 1.0F, 1.0F); EntityUtils.spawnParticlesOnEntity(this.level, (LivingEntity)entityIn, ParticleTypes.POOF, 6, 2); this.setDeltaMovement(new Vec3(entityIn.getX() - this.getX(), entityIn.getY() - this.getY(), entityIn.getZ() - this.getZ()).scale(0.15F)); this.huntingCooldown = 144000; // Large Snakes will spend the next 6 days idling after eating prey entityIn.remove(RemovalReason.KILLED); } return true; } return false; } public boolean attackEntityPartFrom(EntityAnacondaPart anaconda_part, DamageSource source, float amount) { return this.hurt(source, amount); } // Flags Parameters public boolean isEggLayer() { return getEntityData(this.getType()).getFlags(this.getVariant(), "eggLayer") == 1; } public int getMultiparts() { return 3; // TODO: Unused parameter, as all Large Snakes have the same length. Need to consider how to handle multiparts //return getEntityData(this.getType()).getFlags(this.getVariant(), "parts"); } @Override public boolean wantsToLayEggs() { return this.isEggLayer() && this.entityData.get(HAS_EGG); } @Override public void setEggStatus(boolean status) { this.entityData.set(HAS_EGG, status); } @Override public Block getNestType() { return ModBlock.NEST_REPTILE.get(); } @Override public boolean isValidNestBlock(BlockPos pos) { return this.level.isEmptyBlock(pos) && this.level.getBlockState(pos.below()).is(ModTags.ModBlockTags.VALID_REPTILE_NEST) && this.getNestType().defaultBlockState().canSurvive(this.level, pos); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("has_egg", this.wantsToLayEggs()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setEggStatus(compound.getBoolean("has_egg")); } @Override public void updateAttributes() { this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getAttack()); this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getHealth()); this.setHealth(this.getMaxHealth()); } public static class EntityAnacondaPart extends PartEntity<EntityAnaconda> { private final EntityDimensions size; public float scale = 1; public EntityAnacondaPart(EntityAnaconda parent, float sizeX, float sizeY) { super(parent); this.size = EntityDimensions.scalable(sizeX, sizeY); this.refreshDimensions(); } protected void collideWithNearbyEntities() { List<Entity> entities = this.level.getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)); Entity parent = this.getParent(); if (parent != null) { entities.stream().filter(entity -> entity != parent && !(entity instanceof EntityAnacondaPart && ((EntityAnacondaPart) entity).getParent() == parent) && entity.isPushable()).forEach(entity -> entity.push(parent)); } } public InteractionResult mobInteract(Player player, InteractionHand hand) { return this.getParent() == null ? InteractionResult.PASS : this.getParent().mobInteract(player, hand); } public void push(Entity entityIn) { entityIn.push(this); } public boolean canBeCollidedWith() { return true; } public boolean hurt(DamageSource source, float amount) { return !this.isInvulnerableTo(source) && this.getParent().attackEntityPartFrom(this, source, amount); } @Override protected void defineSynchedData() { } @Override protected void readAdditionalSaveData(CompoundTag compound) { } @Override protected void addAdditionalSaveData(CompoundTag compound) { } public boolean is(Entity entityIn) { return this == entityIn || this.getParent() == entityIn; } public Packet<?> getAddEntityPacket() { throw new UnsupportedOperationException(); } public EntityDimensions getSize(Pose poseIn) { return this.size.scale(scale); } } }
16,793
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityTortoise.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/reptile/EntityTortoise.java
package untamedwilds.entity.reptile; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.unique.TortoiseHideInShellGoal; import untamedwilds.init.ModBlock; import untamedwilds.init.ModItems; import untamedwilds.init.ModTags; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityTortoise extends ComplexMobTerrestrial implements ISpecies, INewSkins, INestingMob { private static final EntityDataAccessor<Boolean> HAS_EGG = SynchedEntityData.defineId(EntityTortoise.class, EntityDataSerializers.BOOLEAN); public EntityTortoise(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.ticksToSit = 20; } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(HAS_EGG, false); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 1.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.1D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 6.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0.2D) .add(Attributes.ARMOR, 10D); } public void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(1, new SmartSwimGoal_Land(this)); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 1D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 0.7D)); this.goalSelector.addGoal(2, new TortoiseHideInShellGoal<>(this, LivingEntity.class, 7, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(3, new SmartWanderGoal(this, 1.0D, 400, 0,true)); this.goalSelector.addGoal(3, new LayEggsOnNestGoal(this)); //this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); } public void die(DamageSource cause) { if (cause == DamageSource.ANVIL && !this.isBaby()) { // Advancement Trigger: "Unethical Soup" ItemEntity entityitem = this.spawnAtLocation(new ItemStack(ModItems.FOOD_TURTLE_SOUP.get()), 0.2F); if (entityitem != null) { entityitem.getItem().setCount(1); } } super.die(cause); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } } /* Breeding conditions for the tortoise are: * A nearby tortoise of the opposite gender and the same species */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityTortoise> list = this.level.getEntitiesOfClass(EntityTortoise.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); return list.size() >= 1; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_tortoise", this.getOffspring()); return null; } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (itemstack.isEmpty() && this.isAlive()) { EntityUtils.turnEntityIntoItem(this, "spawn_tortoise"); return InteractionResult.sidedSuccess(this.level.isClientSide); } return super.mobInteract(player, hand); } public boolean hurt(DamageSource source, float amount) { if (source != DamageSource.FALL && this.sitProgress > 0) { amount = amount * 0.2F; } return super.hurt(source, amount); } protected void playStepSound(BlockPos pos, BlockState blockIn) { SoundEvent soundevent = this.isBaby() ? SoundEvents.TURTLE_SHAMBLE_BABY : SoundEvents.TURTLE_SHAMBLE; this.playSound(soundevent, 0.15F, 1.0F); } @Override public boolean wantsToLayEggs() { return this.entityData.get(HAS_EGG); } @Override public void setEggStatus(boolean status) { this.entityData.set(HAS_EGG, status); } @Override public Block getNestType() { return ModBlock.NEST_REPTILE.get(); } @Override public boolean isValidNestBlock(BlockPos pos) { return this.level.isEmptyBlock(pos) && this.level.getBlockState(pos.below()).is(ModTags.ModBlockTags.VALID_REPTILE_NEST) && this.getNestType().defaultBlockState().canSurvive(this.level, pos); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("has_egg", this.wantsToLayEggs()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setEggStatus(compound.getBoolean("has_egg")); } }
6,425
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntitySnake.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/reptile/EntitySnake.java
package untamedwilds.entity.reptile; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ShovelItem; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.target.DontThreadOnMeTarget; import untamedwilds.entity.ai.target.HuntMobTarget; import untamedwilds.init.ModBlock; import untamedwilds.init.ModItems; import untamedwilds.init.ModTags; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntitySnake extends ComplexMobTerrestrial implements ISpecies, INewSkins, INeedsPostUpdate, INestingMob { private static final EntityDataAccessor<Boolean> RATTLER = SynchedEntityData.defineId(EntitySnake.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor<Boolean> HAS_EGG = SynchedEntityData.defineId(EntitySnake.class, EntityDataSerializers.BOOLEAN); public static Animation ANIMATION_TONGUE; public float offset; public EntitySnake(EntityType<? extends ComplexMobTerrestrial> type, Level worldIn) { super(type, worldIn); ANIMATION_TONGUE = Animation.create(10); this.ticksToSit = 20; } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(RATTLER, false); this.entityData.define(HAS_EGG, false); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 2.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.33D) .add(Attributes.FOLLOW_RANGE, 12.0D) .add(Attributes.MAX_HEALTH, 5.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0D) .add(Attributes.ARMOR, 0D); } public void registerGoals() { this.goalSelector.addGoal(1, new SmartSwimGoal_Land(this)); this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.3D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(2, new SmartAvoidGoal<>(this, LivingEntity.class, 16, 1.2D, 1.6D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(3, new SmartWanderGoal(this, 1.0D, true)); this.goalSelector.addGoal(3, new LayEggsOnNestGoal(this)); this.targetSelector.addGoal(3, new HurtByTargetGoal(this)); this.targetSelector.addGoal(3, new HuntMobTarget<>(this, LivingEntity.class, true, 30, false, input -> getEcoLevel(input) < getEcoLevel(this))); this.targetSelector.addGoal(3, new DontThreadOnMeTarget<>(this, LivingEntity.class, true)); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.tickCount % 1000 == 0) { if (this.random.nextInt(40) == 0) { this.spawnAtLocation(new ItemStack(ModItems.MATERIAL_SNAKE_SKIN.get()), 0.2F); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } if (this.tickCount % 120 == 0) { this.setAnimation(ANIMATION_TONGUE); } if (this.getAnimation() == NO_ANIMATION && this.getTarget() == null && !this.isSleeping()) { int i = this.random.nextInt(3000); if (i <= 10 && !this.isInWater() && this.isNotMoving() && this.canMove()) { this.getNavigation().stop(); this.setSitting(true); } if ((i == 11 || this.isInWater() || this.isActive()) && this.isSitting()) { this.setSitting(false); } } this.setAngry(this.getTarget() != null); } else { if (Math.abs(this.getYRot() - this.yRotO) > 0.005) { this.offset = Mth.rotLerp(0.05F, this.offset, (this.getYRot() - this.yRotO)); } } } /* Breeding conditions for the Snake are: * A nearby Snake of the opposite gender and the same species */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntitySnake> list = this.level.getEntitiesOfClass(EntitySnake.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); return list.size() >= 1; } } return false; } protected void playStepSound(BlockPos pos, BlockState blockIn) { } protected SoundEvent getAmbientSound() { if (this.isAngry()) { super.getAmbientSound(); } return null; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_snake", this.getOffspring()); return null; } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (itemstack.isEmpty() && this.isAlive()) { EntityUtils.turnEntityIntoItem(this,"spawn_snake"); return InteractionResult.sidedSuccess(this.level.isClientSide); } return super.mobInteract(player, hand); } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, ANIMATION_TONGUE}; } public boolean doHurtTarget(Entity entityIn) { float f = (float)this.getAttribute(Attributes.ATTACK_DAMAGE).getValue(); boolean flag = entityIn.hurt(DamageSource.mobAttack(this), f); if (flag && this.getVenomStrength() > 0) { if (entityIn instanceof LivingEntity) { ((LivingEntity)entityIn).addEffect(new MobEffectInstance(MobEffects.POISON, 140, this.getVenomStrength() - 1)); } return true; } return flag; } @Override public boolean hurt(DamageSource source, float amount) { Entity entity = source.getDirectEntity(); if (entity instanceof Player player) { if (player.getMainHandItem().getItem() instanceof ShovelItem) { //if (player.getMainHandItem().isCorrectToolForDrops(Blocks.DIRT.defaultBlockState())) { return super.hurt(source, this.getHealth()); } } return super.hurt(source, amount); } // Flags Parameters public Integer getVenomStrength() { return getEntityData(this.getType()).getFlags(this.getVariant(), "venom");} @Override public void updateAttributes() { this.setRattler(getEntityData(this.getType()).getFlags(this.getVariant(), "rattler") == 1); } public boolean isRattler(){ return (this.entityData.get(RATTLER)); } private void setRattler(boolean dimorphism){ this.entityData.set(RATTLER, dimorphism); } public boolean attackEntityPartFrom(DamageSource source, float amount) { return this.hurt(source, amount); } @Override public boolean wantsToLayEggs() { return this.entityData.get(HAS_EGG); } @Override public void setEggStatus(boolean status) { this.entityData.set(HAS_EGG, status); } @Override public Block getNestType() { return ModBlock.NEST_REPTILE.get(); } @Override public boolean isValidNestBlock(BlockPos pos) { return this.level.isEmptyBlock(pos) && this.level.getBlockState(pos.below()).is(ModTags.ModBlockTags.VALID_REPTILE_NEST) && this.getNestType().defaultBlockState().canSurvive(this.level, pos); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("rattler", this.isRattler()); compound.putBoolean("has_egg", this.wantsToLayEggs()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setRattler(compound.getBoolean("rattler")); this.setEggStatus(compound.getBoolean("has_egg")); } }
9,604
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityWhaleShark.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/fish/EntityWhaleShark.java
package untamedwilds.entity.fish; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.util.Mth; import com.mojang.math.Vector3d; import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraftforge.entity.PartEntity; import untamedwilds.entity.*; import untamedwilds.entity.ai.SmartMateGoal; import untamedwilds.init.ModEntity; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityWhaleShark extends ComplexMobAquatic implements ISpecies, INewSkins { public final int length; public final EntityWhaleSharkPart[] whale_shark_parts; public int ringBufferIndex = -1; public final double[][] ringBuffer = new double[64][3]; public EntityWhaleShark(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.length = getMultiparts(); this.whale_shark_parts = new EntityWhaleSharkPart[this.length]; for (int i = 0; i < this.length; i++) { this.whale_shark_parts[i] = new EntityWhaleSharkPart(this, this.getBbWidth(), this.getBbHeight()); } this.turn_speed = 0.1F; } private void setPartPosition(EntityWhaleSharkPart part, double offsetX, double offsetY, double offsetZ) { part.setPos(this.getX() + offsetX * part.scale, this.getY() + offsetY * part.scale, this.getZ() + offsetZ * part.scale); } @Override public boolean isMultipartEntity() { return true; } @Override public PartEntity<?>[] getParts() { return this.whale_shark_parts; } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 3.0D) .add(Attributes.ATTACK_KNOCKBACK, 1.6D) .add(Attributes.MOVEMENT_SPEED, 0.8D) .add(Attributes.FOLLOW_RANGE, 12.0D) .add(Attributes.MAX_HEALTH, 80.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 1D) .add(Attributes.ARMOR, 6D); } public void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.3D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(3, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(4, new SwimGoal(this)); this.targetSelector.addGoal(3, new HurtByTargetGoal(this)); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } if (!this.isNoAi() && !this.isBaby()) { if (this.ringBufferIndex < 0) { for (int i = 0; i < this.ringBuffer.length; ++i) { this.ringBuffer[i][0] = this.getYRot(); this.ringBuffer[i][1] = this.getY(); } } this.ringBufferIndex++; if (this.ringBufferIndex == this.ringBuffer.length) { this.ringBufferIndex = 0; } // Just replaced the contents of Mth.interpolateAngle with the returned formula. Why even is this shit @OnlyIn(Client)??? this.ringBuffer[this.ringBufferIndex][0] = this.yRotO + 0.5F * Mth.wrapDegrees(this.getYRot() - this.yRotO); this.ringBuffer[ringBufferIndex][1] = this.getY(); Vector3d[] avector3d = new Vector3d[this.whale_shark_parts.length]; for (int j = 0; j < this.whale_shark_parts.length; ++j) { this.whale_shark_parts[j].collideWithNearbyEntities(); avector3d[j] = new Vector3d(this.whale_shark_parts[j].getX(), this.whale_shark_parts[j].getY(), this.whale_shark_parts[j].getZ()); } float f15 = (float) (this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F * ((float) Math.PI / 180F); float f16 = Mth.cos(f15); float yaw = this.getYRot() * ((float) Math.PI / 180F); float pitch = this.getXRot() * ((float) Math.PI / 180F); float f3 = Mth.sin(yaw) * (1 - Math.abs(this.getXRot() / 90F)); float f18 = Mth.cos(yaw) * (1 - Math.abs(this.getXRot() / 90F)); double[] adouble = this.getMovementOffsets(5, 1.0F); for (int k = 0; k < getMultiparts(); ++k) { EntityWhaleSharkPart whale_shark_part = this.whale_shark_parts[k]; double[] adouble1 = this.getMovementOffsets(5 + k * 2, 1.0F); float f7 = yaw + (float) Mth.wrapDegrees(adouble1[0] - adouble[0]) * ((float) Math.PI / 180F); float f20 = Mth.sin(f7) * (1 - Math.abs(this.getXRot() / 90F)); float f21 = Mth.cos(f7) * (1 - Math.abs(this.getXRot() / 90F)); float f23 = k == 0 ? (float) (k + 3) : (k + 3) * -1; float value = Mth.clamp(pitch * k, -20, 20); this.setPartPosition(whale_shark_part, -(f3 * 0.5F + f20 * f23) * f16, value, (f18 * 0.5F + f21 * f23) * f16); this.whale_shark_parts[k].xo = avector3d[k].x; this.whale_shark_parts[k].yo = avector3d[k].y; this.whale_shark_parts[k].zo = avector3d[k].z; this.whale_shark_parts[k].xOld = avector3d[k].x; this.whale_shark_parts[k].yOld = avector3d[k].y; this.whale_shark_parts[k].zOld = avector3d[k].z; } } } @Override protected SoundEvent getFlopSound() { return SoundEvents.GUARDIAN_FLOP; } public double[] getMovementOffsets(int offset, float partialTicks) { if (this.isDeadOrDying()) { partialTicks = 0.0F; } partialTicks = 1.0F - partialTicks; int i = this.ringBufferIndex - offset & 63; int j = this.ringBufferIndex - offset - 1 & 63; double[] adouble = new double[3]; double d0 = this.ringBuffer[i][0]; double d1 = this.ringBuffer[j][0] - d0; adouble[0] = d0 + d1 * (double) partialTicks; d0 = this.ringBuffer[i][1]; d1 = this.ringBuffer[j][1] - d0; adouble[1] = d0 + d1 * (double) partialTicks; adouble[2] = Mth.lerp(partialTicks, this.ringBuffer[i][2], this.ringBuffer[j][2]); return adouble; } /* Breeding conditions for the Snake are: * A nearby Snake of the opposite gender and the same species */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityWhaleShark> list = this.level.getEntitiesOfClass(EntityWhaleShark.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { return create_offspring(new EntityWhaleShark(ModEntity.WHALE_SHARK.get(), this.level)); } public boolean attackEntityPartFrom(EntityWhaleSharkPart whale_shark_part, DamageSource source, float amount) { return this.hurt(source, amount); } // Flags Parameters public int getMultiparts() { return 2; } public boolean canBeTargeted() { return false; } public static class EntityWhaleSharkPart extends PartEntity<EntityWhaleShark> { private final EntityDimensions size; public float scale = 1; public EntityWhaleSharkPart(EntityWhaleShark parent, float sizeX, float sizeY) { super(parent); this.size = EntityDimensions.scalable(sizeX, sizeY); this.refreshDimensions(); } protected void collideWithNearbyEntities() { List<Entity> entities = this.level.getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)); Entity parent = this.getParent(); if (parent != null) { entities.stream().filter(entity -> entity != parent && !(entity instanceof EntityWhaleSharkPart && ((EntityWhaleSharkPart) entity).getParent() == parent) && entity.isPushable()).forEach(entity -> entity.push(parent)); } } public InteractionResult mobInteract(Player player, InteractionHand hand) { return this.getParent() == null ? InteractionResult.PASS : this.getParent().mobInteract(player, hand); } public void push(Entity entityIn) { entityIn.push(this); } public boolean canBeCollidedWith() { return true; } public boolean hurt(DamageSource source, float amount) { return !this.isInvulnerableTo(source) && this.getParent().attackEntityPartFrom(this, source, amount); } @Override protected void defineSynchedData() { } @Override protected void readAdditionalSaveData(CompoundTag compound) { } @Override protected void addAdditionalSaveData(CompoundTag compound) { } public boolean is(Entity entityIn) { return this == entityIn || this.getParent() == entityIn; } public Packet<?> getAddEntityPacket() { throw new UnsupportedOperationException(); } public EntityDimensions getSize(Pose poseIn) { return this.size.scale(scale); } } }
10,469
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityFootballFish.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/fish/EntityFootballFish.java
package untamedwilds.entity.fish; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.FluidTags; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.PanicGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.SmartMeleeAttackGoal; import untamedwilds.entity.ai.target.HuntMobTarget; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; public class EntityFootballFish extends ComplexMobAquatic implements ISpecies, INewSkins, INeedsPostUpdate { private static final EntityDataAccessor<Boolean> HAS_MALE = SynchedEntityData.defineId(EntityFootballFish.class, EntityDataSerializers.BOOLEAN); public EntityFootballFish(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(HAS_MALE, false); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 3.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.42D) .add(Attributes.FOLLOW_RANGE, 8.0D) .add(Attributes.MAX_HEALTH, 8.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0D) .add(Attributes.ARMOR, 2D); } protected void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(0, new SmartMeleeAttackGoal(this, 1.8D, false, 2)); this.goalSelector.addGoal(2, new PanicGoal(this, 1.25D)); this.goalSelector.addGoal(4, new SwimGoal(this, 4)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); this.targetSelector.addGoal(2, new HuntMobTarget<>(this, LivingEntity.class, true, false, input -> getEcoLevel(input) < 5)); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.breed(); } if (!this.hasAttachedMale() && this.random.nextInt(40) == 0 && this.getY() < 42) { this.setAttachedMale(true); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } if (this.random.nextInt(18) == 0) ((ServerLevel)this.level).sendParticles(ParticleTypes.GLOW, this.getX(), this.getY() + 0.4, this.getZ(), 1, 0F, 0F, 0F, 0D); } } /* Breeding conditions for the Football Fish are: * Be really deep in the ocean (16 blocks at least), and that's it */ public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.hasAttachedMale() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); for (int i = 0; i <= 16; i++) { BlockState state = level.getBlockState(blockPos.set(this.getX(), this.getY() + i, this.getZ())); if (!state.getFluidState().is(FluidTags.WATER)) { return false; } } this.setAge(this.getPregnancyTime()); return true; } return false; } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { if (this.hasAttachedMale() && itemstack.getItem() == Items.SHEARS) { this.playSound(SoundEvents.SHEEP_SHEAR, 1.5F, 0.8F); this.setAttachedMale(false); this.hurt(DamageSource.mobAttack(player), 1); } } return super.mobInteract(player, hand); } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { if (!this.hasAttachedMale()) this.setAttachedMale(true); EntityUtils.dropEggs(this, "egg_football_fish", this.getOffspring()); return null; } @Override protected SoundEvent getFlopSound() { return SoundEvents.GUARDIAN_FLOP; } @Override public void updateAttributes() { // All Football Fish are female, for the purpose of the mod, males do not exist this.setGender(1); if (this.random.nextInt(3) == 0) { this.setAttachedMale(true); } } public boolean hasAttachedMale(){ return (this.entityData.get(HAS_MALE)); } private void setAttachedMale(boolean attachedMale){ this.entityData.set(HAS_MALE, attachedMale); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("hasMale", this.hasAttachedMale()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setAttachedMale(compound.getBoolean("hasMale")); } }
6,319
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityCatfish.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/fish/EntityCatfish.java
package untamedwilds.entity.fish; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.PanicGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import oshi.util.tuples.Pair; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.ComplexMobAquatic; import untamedwilds.entity.INewSkins; import untamedwilds.entity.ISpecies; import untamedwilds.entity.ai.unique.CatfishGarbageBinGoal; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityCatfish extends ComplexMobAquatic implements ISpecies, INewSkins { public Pair<Float, Float> whisker_offset; private float whisker_y = 0; private float whisker_z = 0; public EntityCatfish(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.whisker_offset = new Pair<>(0F, 0F); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 1.0D) .add(Attributes.ATTACK_KNOCKBACK, 0.3D) .add(Attributes.MOVEMENT_SPEED, 0.65D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 8.0D); } protected void registerGoals() { //super.registerGoals(); this.goalSelector.addGoal(0, new PanicGoal(this, 1.25D)); this.goalSelector.addGoal(2, new CatfishGarbageBinGoal(this, 6, 100)); this.goalSelector.addGoal(4, new SwimGoal(this, 3)); } public void aiStep() { if (!this.level.isClientSide) { if (this.isInWater()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.003D, 0.0D)); } if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.breed(); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } if (this.tickCount % 120 < 11) { if (this.tickCount % 120 == 1) { whisker_y = 0.8F - this.random.nextFloat() * 1.6F; whisker_z = 0.4F - this.random.nextFloat() * 0.8F; } this.whisker_offset = new Pair<>(Mth.lerp(0.1F, whisker_offset.getA(), whisker_y), Mth.lerp(0.1F, whisker_offset.getB(), whisker_z)); } super.aiStep(); } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND) { if (itemstack.getItem().equals(Items.WATER_BUCKET) && this.isAlive()) { EntityUtils.mutateEntityIntoItem(this, player, hand, "bucket_catfish", itemstack); return InteractionResult.sidedSuccess(this.level.isClientSide); } } return super.mobInteract(player, hand); } /* Breeding conditions for the Trevally are: * A nearby Trevally of different gender */ public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityCatfish> list = this.level.getEntitiesOfClass(EntityCatfish.class, this.getBoundingBox().inflate(12.0D, 8.0D, 12.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_catfish", this.getOffspring()); return null; } @Override protected SoundEvent getFlopSound() { return SoundEvents.COD_FLOP; } }
4,702
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityArowana.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/fish/EntityArowana.java
package untamedwilds.entity.fish; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.PanicGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.ComplexMobAquatic; import untamedwilds.entity.INewSkins; import untamedwilds.entity.ISpecies; import untamedwilds.entity.ai.FishBreachGoal; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityArowana extends ComplexMobAquatic implements ISpecies, INewSkins { public EntityArowana(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 2.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.8D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 6.0D); } protected void registerGoals() { this.goalSelector.addGoal(0, new PanicGoal(this, 1.25D)); this.goalSelector.addGoal(4, new SwimGoal(this)); this.goalSelector.addGoal(4, new FishBreachGoal(this, 400, true)); } public void aiStep() { if (!this.level.isClientSide) { if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.breed(); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } // Coerces the Arowana to stay at the surface if (this.getTarget() == null && this.isInWater() && this.tickCount % 10 == 0) { if (level.isWaterAt(this.blockPosition().above(2))) { this.setDeltaMovement(this.getDeltaMovement().add(0, 0.1F, 0)); } } super.aiStep(); } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND) { if (itemstack.getItem().equals(Items.WATER_BUCKET) && this.isAlive()) { EntityUtils.mutateEntityIntoItem(this, player, hand, "bucket_arowana", itemstack); return InteractionResult.sidedSuccess(this.level.isClientSide); } } return super.mobInteract(player, hand); } /* Breeding conditions for the Arowana are: * A nearby Arowana of different gender */ public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityArowana> list = this.level.getEntitiesOfClass(EntityArowana.class, this.getBoundingBox().inflate(12.0D, 8.0D, 12.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_arowana", this.getOffspring()); return null; } @Override protected SoundEvent getFlopSound() { return SoundEvents.COD_FLOP; } }
4,202
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntitySunfish.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/fish/EntitySunfish.java
package untamedwilds.entity.fish; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.PanicGoal; import net.minecraft.world.level.Level; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.ComplexMobAquatic; import untamedwilds.entity.INewSkins; import untamedwilds.entity.ISpecies; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntitySunfish extends ComplexMobAquatic implements ISpecies, INewSkins { public int baskProgress; public EntitySunfish(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 2.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.45D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 40.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 1D) .add(Attributes.ARMOR, 2D); } protected void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(0, new PanicGoal(this, 1.25D)); this.goalSelector.addGoal(4, new SwimGoal(this)); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.breed(); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } if (this.level.isClientSide && !level.isWaterAt(this.blockPosition().above(2)) && this.baskProgress < 100) { this.baskProgress++; } else if (this.level.isClientSide && level.isWaterAt(this.blockPosition().above(2)) && this.baskProgress > 0) { this.baskProgress--; } } /* Breeding conditions for the Sunfish are: * A nearby Sunfish */ public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntitySunfish> list = this.level.getEntitiesOfClass(EntitySunfish.class, this.getBoundingBox().inflate(12.0D, 8.0D, 12.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_sunfish", this.getOffspring()); return null; } @Override protected SoundEvent getFlopSound() { return SoundEvents.GUARDIAN_FLOP; } public boolean canBeAffected(MobEffectInstance potionEffectIn) { return potionEffectIn.getEffect() != MobEffects.POISON && super.canBeAffected(potionEffectIn); } }
3,738
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityTriggerfish.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/fish/EntityTriggerfish.java
package untamedwilds.entity.fish; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.BlockTags; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.goal.MoveToBlockGoal; import net.minecraft.world.entity.ai.goal.PanicGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.animal.TropicalFish; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.pathfinder.Path; import untamedwilds.UntamedWilds; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.ComplexMobAquatic; import untamedwilds.entity.INewSkins; import untamedwilds.entity.ISpecies; import untamedwilds.entity.ai.SmartMeleeAttackGoal; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityTriggerfish extends ComplexMobAquatic implements ISpecies, INewSkins { public EntityTriggerfish(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 2.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.6D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 6.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0D) .add(Attributes.ARMOR, 2D); } protected void registerGoals() { //super.registerGoals(); this.goalSelector.addGoal(0, new SmartMeleeAttackGoal(this, 1.8D, false, 2)); this.goalSelector.addGoal(2, new PanicGoal(this, 1.25D)); this.goalSelector.addGoal(3, new TriggerFishBlowGoal(this, 600)); this.goalSelector.addGoal(4, new SwimGoal(this, 5)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.breed(); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } this.setAngry(this.getTarget() != null); } } /* Breeding conditions for the Triggerfish are: * A nearby Triggerfish of different gender */ public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityTriggerfish> list = this.level.getEntitiesOfClass(EntityTriggerfish.class, this.getBoundingBox().inflate(12.0D, 8.0D, 12.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_triggerfish", this.getOffspring()); return null; } @Override protected SoundEvent getFlopSound() { return SoundEvents.GUARDIAN_FLOP; } public class TriggerFishBlowGoal extends MoveToBlockGoal { private final ComplexMobAquatic taskOwner; private final int chance; private boolean taskComplete; private int counter = 0; public TriggerFishBlowGoal(ComplexMobAquatic entityIn, int chance) { super(entityIn, 1, 3, 4); this.taskOwner = entityIn; this.chance = chance; } public boolean canUse() { super.canUse(); if (this.taskOwner.getRandom().nextInt(this.chance) == 0 || this.blockPos.equals(BlockPos.ZERO)) { this.taskComplete = false; return true; } return false; } @Override protected void moveMobToBlock() { this.mob.getNavigation().moveTo((double)((float)this.blockPos.getX()) + 0.5D, (this.blockPos.getY() + 2), (double)((float)this.blockPos.getZ()) + 0.5D, this.speedModifier); } @Override protected BlockPos getMoveToTarget() { return this.blockPos.above(1); } @Override public boolean canContinueToUse() { //UntamedWilds.LOGGER.info(!this.isReachedTarget() + " " + !this.taskComplete + " " + (this.counter >= 0)); return !this.taskComplete; } @Override public double acceptedDistance() { return 1.8D; } public boolean isInterruptable() { return true; } public void tick() { super.tick(); if (this.counter == 0 && this.isReachedTarget()) { this.taskOwner.getLookControl().setLookAt(this.blockPos.getX() + 0.5, this.blockPos.getY() + 1, this.blockPos.getZ() + 0.5); this.taskOwner.getNavigation().stop(); this.counter = this.taskOwner.getRandom().nextInt(40) + 40; } if (this.counter > 0) { this.counter--; this.taskOwner.getLookControl().setLookAt(this.blockPos.getX() + 0.5, this.blockPos.getY() + 1, this.blockPos.getZ() + 0.5); if (this.counter == 0) { Direction direction = this.taskOwner.getMotionDirection(); this.taskOwner.setDeltaMovement(this.taskOwner.getDeltaMovement().add((double)direction.getStepX() * -0.1D, 0.1D, (double)direction.getStepZ() * -0.1D)); this.taskOwner.getNavigation().stop(); Level worldIn = this.taskOwner.getLevel(); ((ServerLevel)worldIn).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, worldIn.getBlockState(this.blockPos)), this.blockPos.getX() + 0.5, this.blockPos.above().getY(), this.blockPos.getZ() + 0.5, 50, 0.0D, 0.0D, 0.0D, 0.15F); this.taskComplete = true; } } } @Override protected boolean isValidTarget(LevelReader p_25619_, BlockPos blockpos) { // TODO: Option to blow items out of the sand? if (this.taskOwner.level.getBlockState(blockpos).is(BlockTags.SAND) && this.taskOwner.level.getFluidState(blockpos.above()).is(Fluids.WATER) && random.nextInt(2) == 0) { Path path = this.mob.getNavigation().createPath(blockpos, 1); return path != null && path.canReach(); } return false; } } }
7,581
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityShark.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/fish/EntityShark.java
package untamedwilds.entity.fish; import com.github.alexthe666.citadel.animation.Animation; import com.github.alexthe666.citadel.animation.AnimationHandler; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.level.Level; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.MeleeAttackCircle; import untamedwilds.entity.ai.SmartMateGoal; import untamedwilds.entity.ai.target.HuntWeakerTarget; import untamedwilds.entity.ai.target.SmartHurtByTargetGoal; import untamedwilds.entity.ai.unique.SharkSwimmingGoal; import untamedwilds.init.ModEntity; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityShark extends ComplexMobAquatic implements ISpecies, IAnimatedEntity, INeedsPostUpdate, INewSkins { private static final EntityDataAccessor<Boolean> SHORT_FINS = SynchedEntityData.defineId(EntityShark.class, EntityDataSerializers.BOOLEAN); public static Animation ATTACK_THRASH; private int animationTick; private Animation currentAnimation; public int ringBufferIndex = -1; public final double[][] ringBuffer = new double[64][3]; public EntityShark(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); ATTACK_THRASH = Animation.create(15); this.entityData.define(SHORT_FINS, false); this.turn_speed = 0.3F; } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 12.0D) .add(Attributes.ATTACK_KNOCKBACK, 1.4D) .add(Attributes.MOVEMENT_SPEED, 0.8D) .add(Attributes.FOLLOW_RANGE, 32.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 1D) .add(Attributes.MAX_HEALTH, 50.0D); } protected void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(2, new MeleeAttackCircle(this, 2.3D, false, 2)); this.goalSelector.addGoal(3, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(4, new SharkSwimmingGoal(this)); this.targetSelector.addGoal(1, new SmartHurtByTargetGoal(this)); this.targetSelector.addGoal(3, new HuntWeakerTarget<>(this, LivingEntity.class, true)); } public void aiStep() { super.aiStep(); AnimationHandler.INSTANCE.updateAnimations(this); if (!this.level.isClientSide) { this.setAngry(this.getTarget() != null); if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.setAge(this.getPregnancyTime()); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } if (!this.isNoAi() && !this.isBaby()) { if (this.ringBufferIndex < 0) { for (int i = 0; i < this.ringBuffer.length; ++i) { this.ringBuffer[i][0] = this.getYRot(); this.ringBuffer[i][1] = this.getY(); } } this.ringBufferIndex++; if (this.ringBufferIndex == this.ringBuffer.length) { this.ringBufferIndex = 0; } this.ringBuffer[this.ringBufferIndex][0] = this.yRotO + 0.5F * Mth.wrapDegrees(this.getYRot() - this.yRotO); this.ringBuffer[ringBufferIndex][1] = this.getY(); } } public double[] getMovementOffsets(int offset, float partialTicks) { if (this.isDeadOrDying()) { partialTicks = 0.0F; } partialTicks = 1.0F - partialTicks; int i = this.ringBufferIndex - offset & 63; int j = this.ringBufferIndex - offset - 1 & 63; double[] adouble = new double[3]; double d0 = this.ringBuffer[i][0]; double d1 = this.ringBuffer[j][0] - d0; adouble[0] = d0 + d1 * (double) partialTicks; d0 = this.ringBuffer[i][1]; d1 = this.ringBuffer[j][1] - d0; adouble[1] = d0 + d1 * (double) partialTicks; adouble[2] = Mth.lerp(partialTicks, this.ringBuffer[i][2], this.ringBuffer[j][2]); return adouble; } /* Breeding conditions for the Shark are: * A nearby Shark of different gender */ public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityShark> list = this.level.getEntitiesOfClass(EntityShark.class, this.getBoundingBox().inflate(12.0D, 8.0D, 12.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { return create_offspring(new EntityShark(ModEntity.SHARK.get(), this.level)); } @Override protected SoundEvent getFlopSound() { return SoundEvents.COD_FLOP; } public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { this.setAnimation(ATTACK_THRASH); } return flag; } public int getAnimationTick() { return animationTick; } public void setAnimationTick(int tick) { animationTick = tick; } public Animation getAnimation() { return currentAnimation; } public void setAnimation(Animation animation) { currentAnimation = animation; } public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, ATTACK_THRASH}; } // Flags Parameters public boolean isBottomDweller() { return getEntityData(this.getType()).getFlags(this.getVariant(), "bottomDweller") == 1; } @Override public void updateAttributes() { this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getAttack()); this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getHealth()); this.setHealth(this.getMaxHealth()); this.setShortFins(getEntityData(this.getType()).getFlags(this.getVariant(), "shortFins") == 1); } public boolean hasShortFins(){ return (this.entityData.get(SHORT_FINS)); } private void setShortFins(boolean short_fins){ this.entityData.set(SHORT_FINS, short_fins); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("hasShortFins", this.hasShortFins()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setShortFins(compound.getBoolean("hasShortFins")); } }
7,740
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntitySpadefish.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/fish/EntitySpadefish.java
package untamedwilds.entity.fish; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.PanicGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.FishReturnToSchoolGoal; import untamedwilds.entity.ai.FishWanderAsSchoolGoal; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntitySpadefish extends ComplexMobAquatic implements ISpecies, IPackEntity, INewSkins { public EntitySpadefish(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 1.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.75D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 8.0D); } protected void registerGoals() { //super.registerGoals(); this.goalSelector.addGoal(0, new PanicGoal(this, 1.25D)); this.goalSelector.addGoal(4, new FishWanderAsSchoolGoal(this)); this.goalSelector.addGoal(4, new FishReturnToSchoolGoal(this)); } public void aiStep() { if (!this.level.isClientSide) { if (this.herd == null) { IPackEntity.initPack(this); } else if (this.herd.getLeader().equals(this)) { this.herd.tick(); } if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.breed(); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } super.aiStep(); } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND) { if (itemstack.getItem().equals(Items.WATER_BUCKET) && this.isAlive()) { EntityUtils.mutateEntityIntoItem(this, player, hand, "bucket_spadefish", itemstack); return InteractionResult.sidedSuccess(this.level.isClientSide); } } return super.mobInteract(player, hand); } /* Breeding conditions for the Spadefish are: * A nearby Spadefish of different gender */ // TODO: Nearby Kelp/Seagrass as a requirement to Breed public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntitySpadefish> list = this.level.getEntitiesOfClass(EntitySpadefish.class, this.getBoundingBox().inflate(12.0D, 8.0D, 12.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_spadefish", this.getOffspring()); return null; } @Override protected SoundEvent getFlopSound() { return SoundEvents.COD_FLOP; } public boolean shouldLeavePack() { return this.random.nextInt(1000) == 0; } }
4,250
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityTrevally.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/fish/EntityTrevally.java
package untamedwilds.entity.fish; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.PanicGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.FishReturnToSchoolGoal; import untamedwilds.entity.ai.FishWanderAsSchoolGoal; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityTrevally extends ComplexMobAquatic implements ISpecies, IPackEntity, INewSkins { public EntityTrevally(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 1.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.75D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 8.0D); } protected void registerGoals() { //super.registerGoals(); this.goalSelector.addGoal(0, new PanicGoal(this, 1.25D)); this.goalSelector.addGoal(4, new FishWanderAsSchoolGoal(this)); this.goalSelector.addGoal(4, new FishReturnToSchoolGoal(this)); } public void aiStep() { if (!this.level.isClientSide) { if (this.herd == null) { IPackEntity.initPack(this); } else if (this.herd.getLeader().equals(this)) { this.herd.tick(); } if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.breed(); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } super.aiStep(); } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND) { if (itemstack.getItem().equals(Items.WATER_BUCKET) && this.isAlive()) { EntityUtils.mutateEntityIntoItem(this, player, hand, "bucket_trevally", itemstack); return InteractionResult.sidedSuccess(this.level.isClientSide); } } return super.mobInteract(player, hand); } /* Breeding conditions for the Trevally are: * A nearby Trevally of different gender */ public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityTrevally> list = this.level.getEntitiesOfClass(EntityTrevally.class, this.getBoundingBox().inflate(12.0D, 8.0D, 12.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_trevally", this.getOffspring()); return null; } @Override protected SoundEvent getFlopSound() { return SoundEvents.COD_FLOP; } public boolean shouldLeavePack() { return this.random.nextInt(1000) == 0; } }
4,182
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityNewt.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/amphibian/EntityNewt.java
package untamedwilds.entity.amphibian; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.animal.axolotl.Axolotl; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.pathfinder.BlockPathTypes; import untamedwilds.UntamedWilds; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.control.look.SmartSwimmerLookControl; import untamedwilds.entity.ai.control.movement.SmartSwimmingMoveControl; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityNewt extends ComplexMobAmphibious implements ISpecies, INewSkins { public int swimProgress; public float offset; public EntityNewt(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.moveControl = new SmartSwimmingMoveControl(this, 40, 5, 0.25F, 0.3F, true); this.lookControl = new SmartSwimmerLookControl(this, 20); //this.setPathfindingMalus(BlockPathTypes.WATER, this.isAquatic() ? 0.0F : -1); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 1.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.7D) .add(Attributes.FOLLOW_RANGE, 8.0D) .add(Attributes.MAX_HEALTH, 2.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0D); } public void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 1.4D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 0.7D)); this.goalSelector.addGoal(2, new SmartAvoidGoal<>(this, LivingEntity.class, (float)this.getAttributeValue(Attributes.FOLLOW_RANGE), 1D, 1.3D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(3, new AmphibiousTransition(this, 1D)); //this.goalSelector.addGoal(3, new RandomSwimmingGoal(this, 1D, 60)); //this.goalSelector.addGoal(5, new SmartWanderGoal(this, 1D, 120, 0, false)); this.goalSelector.addGoal(6, new SmartLookAtGoal(this, LivingEntity.class, 10.0F)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); } public float getWalkTargetValue(BlockPos p_149140_, LevelReader p_149141_) { return 0.0F; } private boolean isAquatic() { return getEntityData(this.getType()).getFlags(this.getVariant(), "isAquatic") == 1; } public boolean wantsToBeOnLand() { return !this.isAquatic(); } public boolean wantsToBeInWater() { return this.isAquatic(); } public boolean isPushedByFluid() { return false; } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.isInWater()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.003D, 0.0D)); } if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.breed(); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } else { if (Math.abs(this.getYRot() - this.yRotO) > 0.005) { this.offset = Mth.rotLerp(0.05F, this.offset, (this.getYRot() - this.yRotO)); } if (this.isInWater() && !this.isOnGround() && this.swimProgress < 20) { this.swimProgress++; } else if ((!this.isInWater() || this.isOnGround()) && this.swimProgress > 0) { this.swimProgress--; } } } /* Breeding conditions for the giant salamander are: * A nearby giant salamander of the opposite gender and the same species */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityNewt> list = this.level.getEntitiesOfClass(EntityNewt.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_newt", this.getOffspring()); return null; } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND) { if (itemstack.getItem().equals(Items.WATER_BUCKET) && this.isAlive()) { EntityUtils.mutateEntityIntoItem(this, player, hand, "bucket_newt", itemstack); return InteractionResult.sidedSuccess(this.level.isClientSide); } } return super.mobInteract(player, hand); } protected void playStepSound(BlockPos pos, BlockState blockIn) { SoundEvent soundevent = SoundEvents.TURTLE_SHAMBLE_BABY; this.playSound(soundevent, 0.15F, 1.0F); } public float getModelScale() { return 0.8F; } }
6,473
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityGiantSalamander.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/amphibian/EntityGiantSalamander.java
package untamedwilds.entity.amphibian; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; 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.BlockTags; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import untamedwilds.UntamedWilds; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.control.look.SmartSwimmerLookControl; import untamedwilds.entity.ai.control.movement.SmartSwimmingMoveControl; import untamedwilds.entity.ai.target.HuntMobTarget; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityGiantSalamander extends ComplexMobAmphibious implements ISpecies, INeedsPostUpdate, INewSkins { public static Animation ATTACK_SWALLOW; public int swimProgress; public float offset; public EntityGiantSalamander(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.moveControl = new SmartSwimmingMoveControl(this, 40, 5, 0.25F, 0.3F, true); this.lookControl = new SmartSwimmerLookControl(this, 20); ATTACK_SWALLOW = Animation.create(15); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 2.0D) .add(Attributes.ATTACK_KNOCKBACK, 0.1D) .add(Attributes.MOVEMENT_SPEED, 0.8D) .add(Attributes.FOLLOW_RANGE, 8.0D) .add(Attributes.MAX_HEALTH, 10.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0D); } public void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 1.4D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 0.7D)); this.goalSelector.addGoal(2, new SmartAvoidGoal<>(this, LivingEntity.class, (float)this.getAttributeValue(Attributes.FOLLOW_RANGE), 1D, 1.1D, input -> getEcoLevel(input) > getEcoLevel(this))); //this.goalSelector.addGoal(3, new AmphibiousTransition(this, 1D)); this.goalSelector.addGoal(4, new AmphibiousRandomSwimGoal(this, 0.7, 400)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); this.targetSelector.addGoal(3, new HuntMobTarget<>(this, LivingEntity.class, true, false, input -> getEcoLevel(input) < getEcoLevel(this) && input.isInWater())); } public float getWalkTargetValue(BlockPos p_149140_, LevelReader p_149141_) { return 0.0F; } public boolean wantsToBeOnLand() { return this.level.isRainingAt(this.blockPosition()); } public boolean wantsToBeInWater() { return true; } public boolean isPushedByFluid() { return false; } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.isInWater()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.003D, 0.0D)); if (!this.isNotMoving() && this.random.nextInt(5) == 0 && this.getDeltaMovement().horizontalDistance() > 0.08) { Vec3 testpos = this.position().add(Math.cos(Math.toRadians(this.getYRot()+ 90)) * -0.8, 0, Math.sin(Math.toRadians(this.getYRot() + 90)) * -0.8); BlockPos testblockpos = new BlockPos(testpos); if (level.getBlockState(new BlockPos(testblockpos.below())).is(BlockTags.MINEABLE_WITH_SHOVEL)) ((ServerLevel)this.level).sendParticles(new BlockParticleOption(ParticleTypes.FALLING_DUST, this.level.getBlockState(testblockpos.below())), testpos.x, testpos.y + 0.2, testpos.z, 2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, 0); else ((ServerLevel)this.level).sendParticles(ParticleTypes.UNDERWATER, testpos.x, testpos.y + 0.2, testpos.z, 2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, 0); } } if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.breed(); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } else { if (Math.abs(this.getYRot() - this.yRotO) > 0.005) { this.offset = Mth.rotLerp(0.05F, this.offset, (this.getYRot() - this.yRotO)); } if (this.isInWater() && !this.isNotMoving()) { if (this.swimProgress < 20) this.swimProgress++; } else if ((!this.isInWater() || this.isNotMoving()) && this.swimProgress > 0) { this.swimProgress--; } } } /* Breeding conditions for the giant salamander are: * A nearby giant salamander of the opposite gender and the same species */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityGiantSalamander> list = this.level.getEntitiesOfClass(EntityGiantSalamander.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } } return false; } public boolean doHurtTarget(Entity entityIn) { float f = (float)this.getAttribute(Attributes.ATTACK_DAMAGE).getValue(); boolean flag = entityIn.hurt(DamageSource.mobAttack(this), f); if (flag) { if (entityIn instanceof LivingEntity && entityIn.getBbWidth() * entityIn.getBbHeight() < 0.4F && !(entityIn instanceof TamableAnimal && ((TamableAnimal) entityIn).isTame())) { this.setAnimation(ATTACK_SWALLOW); this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.BEEHIVE_ENTER, SoundSource.BLOCKS, 1.0F, 1.0F); EntityUtils.spawnParticlesOnEntity(this.level, (LivingEntity)entityIn, ParticleTypes.POOF, 6, 2); this.setDeltaMovement(new Vec3(entityIn.getX() - this.getX(), entityIn.getY() - this.getY(), entityIn.getZ() - this.getZ()).scale(0.15F)); this.huntingCooldown = 12000; entityIn.remove(RemovalReason.KILLED); } return true; } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_giant_salamander", this.getOffspring()); return null; } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND) { if (itemstack.getItem().equals(Items.WATER_BUCKET) && this.isAlive()) { EntityUtils.mutateEntityIntoItem(this, player, hand, "bucket_giant_salamander", itemstack); return InteractionResult.sidedSuccess(this.level.isClientSide); } } return super.mobInteract(player, hand); } protected void playStepSound(BlockPos pos, BlockState blockIn) { SoundEvent soundevent = this.isBaby() ? SoundEvents.TURTLE_SHAMBLE_BABY : SoundEvents.TURTLE_SHAMBLE; this.playSound(soundevent, 0.15F, 1.0F); } public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, ATTACK_SWALLOW}; } @Override public void updateAttributes() { this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getAttack()); this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getHealth()); this.setHealth(this.getMaxHealth()); } }
9,144
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntitySpitter.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/relict/EntitySpitter.java
package untamedwilds.entity.relict; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import untamedwilds.UntamedWilds; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.target.ProtectChildrenTarget; import untamedwilds.entity.ai.target.SmartHurtByTargetGoal; import untamedwilds.entity.ai.target.SmartOwnerHurtTargetGoal; import untamedwilds.entity.ai.unique.SpitterAttackGoal; import untamedwilds.entity.ai.unique.SpitterTerritorialityGoal; import untamedwilds.init.ModBlock; import untamedwilds.init.ModEntity; import untamedwilds.init.ModTags; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntitySpitter extends ComplexMobTerrestrial implements ISpecies, INewSkins, INestingMob, INeedsPostUpdate { private static final EntityDataAccessor<Boolean> CAN_GROW = SynchedEntityData.defineId(EntitySpitter.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor<Boolean> HAS_EGG = SynchedEntityData.defineId(EntitySpitter.class, EntityDataSerializers.BOOLEAN); public static Animation ATTACK_MAUL_RIGHT; public static Animation ATTACK_MAUL_LEFT; public static Animation ATTACK_SPIT; public static Animation ANIMATION_EAT; public static Animation IDLE_WATCH; public static Animation IDLE_TALK; public int aggroProgress; public EntitySpitter(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); ATTACK_MAUL_RIGHT = Animation.create(22); ATTACK_MAUL_LEFT = Animation.create(22); ATTACK_SPIT = Animation.create(20); IDLE_TALK = Animation.create(40); IDLE_WATCH = Animation.create(80); ANIMATION_EAT = Animation.create(80); this.turn_speed = 0.3F; } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(CAN_GROW, false); this.entityData.define(HAS_EGG, false); } public void registerGoals() { this.goalSelector.addGoal(1, new SmartSwimGoal_Land(this)); this.goalSelector.addGoal(2, new FindItemsGoal(this, 12, true)); this.goalSelector.addGoal(2, new SpitterAttackGoal(this, 2.0D, false, 1)); this.goalSelector.addGoal(3, new SmartAvoidGoal<>(this, LivingEntity.class, 16, 1.2D, 1.6D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(4, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(4, new GrazeGoal(this, 300) { public boolean isGrazeable() { return (this.entityWorld.getBlockState(this.testpos).is(Blocks.SMALL_DRIPLEAF) || this.entityWorld.getBlockState(this.testpos.below()).getBlock() == Blocks.CLAY); } }); this.goalSelector.addGoal(4, new GotoSleepGoal(this, 1D)); //this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25D)); this.goalSelector.addGoal(5, new SmartWanderGoal(this, 1D, true)); this.goalSelector.addGoal(6, new SmartLookAtGoal(this, LivingEntity.class, 10.0F)); this.targetSelector.addGoal(1, new SmartHurtByTargetGoal(this).setAlertOthers(EntitySpitter.class)); this.targetSelector.addGoal(3, new ProtectChildrenTarget<>(this, LivingEntity.class, true, input -> !(input instanceof EntitySpitter))); this.targetSelector.addGoal(4, new SpitterTerritorialityGoal<>(this, EntitySpitter.class, true)); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 8.0D) .add(Attributes.ATTACK_KNOCKBACK, 0.8D) .add(Attributes.MOVEMENT_SPEED, 0.16D) .add(Attributes.FOLLOW_RANGE, 32D) .add(Attributes.MAX_HEALTH, 40.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0.8D) .add(Attributes.ARMOR, 0D); } /* Breeding conditions for the Spitter are: * Less than 6 other Spitters (larva or adult) entities nearby */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntitySpitter> list = this.level.getEntitiesOfClass(EntitySpitter.class, this.getBoundingBox().inflate(32.0D, 12.0D, 32.0D)); return list.size() < 6; } } return false; } @Override public float getStepHeight() { return 1; } public void setAge(int age) { int i = this.age; if (this.isBaby() && i < 100 && !this.getWantsToGrow()) super.setAge(Math.max(-12000, ConfigGamerules.cycleLength.get() / -2)); else { super.setAge(age); } } public boolean wantsToGrow() { if (this.isBaby()) { List<EntitySpitter> list = this.level.getEntitiesOfClass(EntitySpitter.class, this.getBoundingBox().inflate(32.0D, 16.0D, 32.0D)); for (EntitySpitter spitter : list) { if (spitter.getGender() == this.getGender() && (!spitter.isBaby() || spitter.getWantsToGrow())) return false; } return true; } return false; } @Nullable public EntitySpitter getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { return create_offspring(new EntitySpitter(ModEntity.SPITTER.get(), this.level)); } public boolean isPushedByFluid() { return false; } public Animation getAnimationEat() { return ANIMATION_EAT; } public void aiStep() { if (!this.level.isClientSide) { if (this.tickCount % 600 == 0) { if (!this.getWantsToGrow()) this.setWantsToGrow(this.wantsToGrow()); if (this.wantsToLayEggs() && !this.isMale()) { for(int k = 0; k < 3; ++k) { BlockState state = ModBlock.EGG_SPITTER.get().defaultBlockState(); BlockPos blockpos = this.blockPosition().offset(this.random.nextInt(3) - 1, 1 - this.random.nextInt(3), this.random.nextInt(3) - 1); if (this.getLevel().isInWorldBounds(blockpos) && this.getLevel().getBlockState(blockpos).is(Blocks.WATER) && state.canSurvive(this.getLevel(), blockpos)) { this.getLevel().setBlock(blockpos, state, 2); this.setEggStatus(false); } } } } // Boosted Regeneration if (this.level.getGameTime() % 500 == 0) { this.addHunger(-3); if (!this.isStarving()) { this.heal(2.0F); } } // Random idle animations if (this.getAnimation() == NO_ANIMATION && this.getTarget() == null && !this.isSleeping()) { if (this.getCommandInt() == 0) { int i = this.random.nextInt(3000); if (i == 0 && !this.isInWater() && this.isNotMoving() && this.canMove() && this.isActive()) { this.getNavigation().stop(); this.setSitting(true); } else if ((i == 1 || this.isInWater()) && this.isSitting() && this.getCommandInt() < 2) { this.setSitting(false); } else if (i < 25 && !this.isInWater() && !this.isBaby()) { this.setAnimation(IDLE_TALK); } else if (i > 2980 && !this.isInWater() && !this.isBaby() && this.canMove() && this.isNotMoving()) { this.setAnimation(IDLE_WATCH); } } } if (this.getTarget() != null && (this.getAnimation() == ATTACK_SPIT || this.isBaby())) { this.setDeltaMovement(this.getDeltaMovement().scale(0.6F)); if (this.getAnimationTick() == 14) performRangedAttack(this.getTarget(), 0.5F); } this.setAngry(this.getTarget() != null); } if (this.getAnimation() == ANIMATION_EAT && (this.getAnimationTick() == 10 || this.getAnimationTick() == 20 || this.getAnimationTick() == 30)) { this.playSound(SoundEvents.HORSE_EAT,1.5F, 0.8F); } if (this.getAnimation() == ATTACK_MAUL_RIGHT && this.getAnimationTick() == 10) { this.playSound(SoundEvents.PLAYER_ATTACK_SWEEP,1.5F, 0.8F); } if (this.getAnimation() == IDLE_TALK && this.getAnimationTick() == 1 && this.getAmbientSound() != null) { this.playSound(this.getAmbientSound(), this.getSoundVolume(), this.getVoicePitch()); } if (this.level.isClientSide && this.isAngry() && this.aggroProgress < 40) { this.aggroProgress++; } else if (this.level.isClientSide && !this.isAngry() && this.aggroProgress > 0) { this.aggroProgress--; } super.aiStep(); } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.HOGLIN_STEP, 0.15F, 1.0F); } @Override protected void reassessTameGoals() { if (this.isTame()) { if (UntamedWilds.DEBUG) { UntamedWilds.LOGGER.info("Updating AI tasks for tamed mob"); } this.goalSelector.addGoal(3, new SmartFollowOwnerGoal(this, 2.3D, 12.0F, 3.0F)); this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this)); this.targetSelector.addGoal(2, new SmartOwnerHurtTargetGoal(this)); } } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { if (!this.isTame() && this.isBaby() && EntityUtils.hasFullHealth(this) && this.isFood(itemstack)) { this.playSound(SoundEvents.HORSE_EAT, 1.5F, 0.8F); if (this.getRandom().nextInt(3) == 0) { this.tame(player); EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.HEART, 3, 6); } else { EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.SMOKE, 3, 3); } } } return super.mobInteract(player, hand); } public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { Animation anim = chooseAttackAnimation(); this.setAnimation(anim); this.setAnimationTick(0); } return flag; } public boolean hurt(DamageSource damageSource, float amount) { // Retaliate I: Mob will strike back when attacked by its current target float f = this.getHealth(); if (!this.level.isClientSide && !this.isNoAi() && this.getTarget() == damageSource.getEntity() && amount < f && (damageSource.getEntity() != null || damageSource.getDirectEntity() != null) && damageSource.getEntity() instanceof LivingEntity && (damageSource.getEntity() instanceof TamableAnimal tamable && tamable.getOwner() != null)) { if (this.hasLineOfSight(damageSource.getEntity()) && !damageSource.getEntity().isInvulnerable() && this.getAnimation() == NO_ANIMATION) { this.doHurtTarget(damageSource.getEntity()); } } return super.hurt(damageSource, amount); } private Animation chooseAttackAnimation() { return switch (this.random.nextInt(2)) { case 0 -> ATTACK_MAUL_LEFT; case 1 -> ATTACK_MAUL_RIGHT; default -> ATTACK_MAUL_RIGHT; }; } //public Animation getAnimationEat() { return ANIMATION_EAT; } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, ATTACK_MAUL_RIGHT, ATTACK_MAUL_LEFT, ATTACK_SPIT, IDLE_WATCH, IDLE_TALK, ANIMATION_EAT}; } public boolean canBeAffected(MobEffectInstance potionEffectIn) { return potionEffectIn.getEffect() != MobEffects.POISON && super.canBeAffected(potionEffectIn); } protected float getStandingEyeHeight(Pose poseIn, EntityDimensions sizeIn) { return sizeIn.height * 0.9F; } public boolean getWantsToGrow(){ return (this.entityData.get(CAN_GROW)); } private void setWantsToGrow(boolean can_grow){ this.entityData.set(CAN_GROW, can_grow); } @Override public boolean wantsToLayEggs() { return this.entityData.get(HAS_EGG); } @Override public void setEggStatus(boolean status) { this.entityData.set(HAS_EGG, status); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("canGrow", this.getWantsToGrow()); compound.putBoolean("has_egg", this.wantsToLayEggs()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setWantsToGrow(compound.getBoolean("canGrow")); this.setEggStatus(compound.getBoolean("has_egg")); } public void performRangedAttack(LivingEntity entityIn, float p_33318_) { ProjectileSpit camel_spit = new ProjectileSpit(this.level, this, new MobEffectInstance(MobEffects.POISON, 100, 0)); double d0 = entityIn.getX() - this.getX(); double d1 = entityIn.getY(0.3333333333333333D) - camel_spit.getY(); double d2 = entityIn.getZ() - this.getZ(); double d3 = Math.sqrt(d0 * d0 + d2 * d2) * (double)0.2F; camel_spit.shoot(d0, d1 + d3, d2, 1.5F, 6.0F); this.getLookControl().setLookAt(entityIn); if (!this.isSilent()) { this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.LLAMA_SPIT, this.getSoundSource(), 1.0F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F); } this.level.addFreshEntity(camel_spit); } @Override public Block getNestType() { return ModBlock.EGG_SPITTER.get(); } @Override public boolean isValidNestBlock(BlockPos pos) { return this.level.isEmptyBlock(pos) && this.level.getBlockState(pos.below()).is(ModTags.ModBlockTags.VALID_REPTILE_NEST) && this.getNestType().defaultBlockState().canSurvive(this.level, pos); } @Override public void updateAttributes() { int rand = this.getRandom().nextInt(5); if (rand > 3 && !this.isMale()) { this.breed(); } } }
16,065
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityKingCrab.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/arthropod/EntityKingCrab.java
package untamedwilds.entity.arthropod; import com.github.alexthe666.citadel.animation.Animation; import com.github.alexthe666.citadel.animation.AnimationHandler; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.BlockTags; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.MobType; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; import net.minecraft.world.entity.ai.goal.RandomStrollGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.ComplexMobAmphibious; import untamedwilds.entity.INewSkins; import untamedwilds.entity.ISpecies; import untamedwilds.entity.ai.SmartAvoidGoal; import untamedwilds.entity.ai.SmartMateGoal; import untamedwilds.entity.ai.SmartWanderGoal; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityKingCrab extends ComplexMobAmphibious implements ISpecies, INewSkins, IAnimatedEntity { private int animationTick; private Animation currentAnimation; public static Animation EAT_LEFT; public static Animation EAT_RIGHT; public static Animation EAT_BOTH; public EntityKingCrab(EntityType<? extends EntityKingCrab> type, Level worldIn) { super(type, worldIn); //this.moveControl = new SmartSwimmingMoveControl(this, 40, 5, 1F, 0.6F, true); EAT_LEFT = Animation.create(56); EAT_RIGHT = Animation.create(56); EAT_BOTH = Animation.create(80); this.maxUpStep = 1; } @Override public MobType getMobType() { return MobType.ARTHROPOD; } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 3.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.4D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 8.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0D) .add(Attributes.ARMOR, 4D); } public void registerGoals() { this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.3D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(2, new SmartAvoidGoal<>(this, LivingEntity.class, 16, 1.2D, 1.6D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(3, new RandomStrollGoal(this, 1.0D, 240)); this.targetSelector.addGoal(3, new HurtByTargetGoal(this)); } public float getWalkTargetValue(BlockPos p_149140_, LevelReader p_149141_) { return 0.0F; } public boolean wantsToBeOnLand() { return this.level.isRainingAt(this.blockPosition()); } public boolean wantsToBeInWater() { return true; } public boolean isPushedByFluid() { return false; } //public float getWaterSlowDown() { } public void aiStep() { super.aiStep(); AnimationHandler.INSTANCE.updateAnimations(this); if (!this.level.isClientSide) { if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.breed(); } } if (this.isInWater()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.005D, 0.0D)); } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } if (this.isInWater() && this.getAnimation() == NO_ANIMATION && this.getTarget() == null && this.level.getBlockState(this.blockPosition().below()).is(BlockTags.MINEABLE_WITH_SHOVEL)) { if (this.getCommandInt() == 0) { int i = this.random.nextInt(3000); if (i > 2940 && i < 2960) this.setAnimation(EAT_RIGHT); if (i > 2960 && i < 2980) this.setAnimation(EAT_LEFT); if (i > 2980) this.setAnimation(EAT_BOTH); } } if (this.getAnimation() != NO_ANIMATION) { if (((this.getAnimation() == EAT_LEFT || this.getAnimation() == EAT_RIGHT) && (this.getAnimationTick() == 20)) || (this.getAnimation() == EAT_BOTH && (this.getAnimationTick() == 20 || this.getAnimationTick() == 44))) { ((ServerLevel)this.level).sendParticles(new BlockParticleOption(ParticleTypes.FALLING_DUST, this.level.getBlockState(this.blockPosition().below())), this.getX(), this.getY(), this.getZ(), 3, 0.0D, 0.0D, 0.0D, 0.15F); this.playSound(SoundEvents.SHOVEL_FLATTEN, 0.2F, 0.7F); } } } if (this.level.isClientSide()) { } } /* Breeding conditions for the Tarantula are: * A nearby Tarantula of the opposite gender and the same species */ public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.isInWater() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityKingCrab> list = this.level.getEntitiesOfClass(EntityKingCrab.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_king_crab", this.getOffspring()); return null; } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND) { if (itemstack.getItem().equals(Items.WATER_BUCKET) && this.isAlive()) { EntityUtils.mutateEntityIntoItem(this, player, hand, "bucket_king_crab", itemstack); return InteractionResult.sidedSuccess(this.level.isClientSide); } } return super.mobInteract(player, hand); } protected float getSoundVolume() { return 0.4F; } public int getAnimationTick() { return animationTick; } public void setAnimationTick(int tick) { animationTick = tick; } public Animation getAnimation() { return currentAnimation; } public void setAnimation(Animation animation) { currentAnimation = animation; } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, EAT_RIGHT, EAT_LEFT, EAT_BOTH}; } }
7,745
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityTarantula.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/arthropod/EntityTarantula.java
package untamedwilds.entity.arthropod; import net.minecraft.core.BlockPos; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.ai.navigation.PathNavigation; import net.minecraft.world.entity.ai.navigation.WallClimberNavigation; import net.minecraft.world.entity.animal.horse.AbstractHorse; import net.minecraft.world.entity.monster.Spider; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.INewSkins; import untamedwilds.entity.ISpecies; import untamedwilds.entity.ai.SmartAvoidGoal; import untamedwilds.entity.ai.SmartMateGoal; import untamedwilds.entity.ai.SmartSwimGoal_Land; import untamedwilds.entity.ai.target.DontThreadOnMeTarget; import untamedwilds.entity.ai.target.HuntMobTarget; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; // TODO: The whole climbing is terrible, refactor it public class EntityTarantula extends ComplexMob implements ISpecies, INewSkins { private static final EntityDataAccessor<Boolean> CLIMBING = SynchedEntityData.defineId(EntityTarantula.class, EntityDataSerializers.BOOLEAN); public int aggroProgress; public int climbProgress; public boolean invertClimbing = false; //public int webProgress; public EntityTarantula(EntityType<? extends EntityTarantula> type, Level worldIn) { super(type, worldIn); this.entityData.define(CLIMBING, false); } @Override public MobType getMobType() { return MobType.ARTHROPOD; } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 1.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.2D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 2.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0D) .add(Attributes.ARMOR, 0D); } public void registerGoals() { this.goalSelector.addGoal(1, new SmartSwimGoal_Land(this)); this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.3D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(2, new SmartAvoidGoal<>(this, LivingEntity.class, 16, 1.2D, 1.6D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(3, new WaterAvoidingRandomStrollGoal(this, 1.0D)); this.targetSelector.addGoal(3, new HurtByTargetGoal(this)); this.targetSelector.addGoal(3, new HuntMobTarget<>(this, LivingEntity.class, true, 30, false, input -> getEcoLevel(input) < getEcoLevel(this))); this.targetSelector.addGoal(3, new DontThreadOnMeTarget<>(this, LivingEntity.class, true)); } protected PathNavigation createNavigation(Level p_33802_) { return new WallClimberNavigation(this, p_33802_); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.tickCount % 1000 == 0) { if (this.wantsToBreed() && !this.isMale()) { this.breed(); } } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } this.setAngry(this.getTarget() != null); this.setClimbing(this.horizontalCollision && nextToClimbableBlock(this)); if (!this.isOnGround() && !this.isClimbing() && this.getDeltaMovement().y() < 0 && nextToClimbableBlock(this)){ this.setDeltaMovement(this.getDeltaMovement().multiply(0, 0.5, 0)); this.setClimbing(true); } } if (this.level.isClientSide()) { if (this.isAngry() && this.aggroProgress < 40) this.aggroProgress++; else if (!this.isAngry() && this.aggroProgress > 0) this.aggroProgress--; if (this.isClimbing() && this.climbProgress < 20) this.climbProgress++; else if (!this.isClimbing() && this.climbProgress > 0) this.climbProgress--; if (this.climbProgress % 20 != 0 && this.invertClimbing != (this.getDeltaMovement().y() < 0)) this.invertClimbing = !this.isOnGround() && this.getDeltaMovement().y() < 0; } } public boolean onClimbable() { return this.isClimbing(); } /* Breeding conditions for the Tarantula are: * A nearby Tarantula of the opposite gender and the same species */ public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && !this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityTarantula> list = this.level.getEntitiesOfClass(EntityTarantula.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_tarantula", this.getOffspring()); return null; } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (itemstack.getItem() == Items.GLASS_BOTTLE && this.isAlive()) { EntityUtils.turnEntityIntoItem(this, "bottle_tarantula"); itemstack.shrink(1); return InteractionResult.sidedSuccess(this.level.isClientSide); } return super.mobInteract(player, hand); } public boolean causeFallDamage(float p_148859_, float p_148860_, DamageSource p_148861_) { return false; } public boolean doHurtTarget(Entity entityIn) { float f = (float)this.getAttribute(Attributes.ATTACK_DAMAGE).getValue(); boolean flag = entityIn.hurt(DamageSource.mobAttack(this), f); if (flag) { if (entityIn instanceof LivingEntity) { ((LivingEntity)entityIn).addEffect(new MobEffectInstance(MobEffects.POISON, 80, 0)); } return true; } return false; } public boolean canBeAffected(MobEffectInstance potionEffectIn) { return potionEffectIn.getEffect() != MobEffects.POISON && super.canBeAffected(potionEffectIn); } protected float getSoundVolume() { return 0.4F; } public boolean isClimbing() { return this.entityData.get(CLIMBING) && nextToClimbableBlock(this); } public static boolean nextToClimbableBlock(EntityTarantula entityIn) { Level world = entityIn.getLevel(); BlockPos pos_1 = entityIn.blockPosition().offset(Math.cos(Math.toRadians(entityIn.getYRot() + 90)) * 1.2, 0, Math.sin(Math.toRadians(entityIn.getYRot() + 90)) * 1.2); BlockPos pos_2 = entityIn.blockPosition().offset(Math.cos(Math.toRadians(entityIn.getYRot() + 90)) * -1.2, 0, Math.sin(Math.toRadians(entityIn.getYRot() + 90)) * -1.2); BlockState block_1 = world.getBlockState(pos_1); BlockState block_2 = world.getBlockState(pos_2); return block_1.isCollisionShapeFullBlock(world, pos_1) || block_2.isCollisionShapeFullBlock(world, pos_2); } public void setClimbing(boolean p_33820_) { this.entityData.set(CLIMBING, p_33820_); } }
8,737
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityOpossum.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityOpossum.java
package untamedwilds.entity.mammal; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.BlockTags; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.AvoidEntityGoal; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.ai.targeting.TargetingConditions; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import untamedwilds.entity.*; import untamedwilds.entity.ai.SmartMateGoal; import untamedwilds.entity.ai.SmartMeleeAttackGoal; import untamedwilds.entity.ai.SmartWanderGoal; import untamedwilds.entity.ai.control.look.SmartSwimmerLookControl; import untamedwilds.entity.ai.target.HuntMobTarget; import untamedwilds.init.ModEntity; import untamedwilds.init.ModSounds; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.EnumSet; import java.util.List; import java.util.function.Predicate; public class EntityOpossum extends ComplexMobTerrestrial implements ISpecies, INewSkins { private static final EntityDataAccessor<Boolean> PLAYING_DEAD = SynchedEntityData.defineId(EntityOpossum.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor<Integer> JOEYS = SynchedEntityData.defineId(EntityOpossum.class, EntityDataSerializers.INT); public static Animation IDLE_SCRATCH; public static Animation THREAT_BACK_OFF; // TODO: Some kind of chest raiding // TODO: Ain't coding climbing AI public EntityOpossum(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); //this.moveControl = new SmartSwimmingMoveControl(this, 40, 5, 0.25F, 0.3F, true); this.lookControl = new SmartSwimmerLookControl(this, 20); IDLE_SCRATCH = Animation.create(80); THREAT_BACK_OFF = Animation.create(30); this.ticksToSit = 20; } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(PLAYING_DEAD, false); this.entityData.define(JOEYS, 0); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 2.0D) .add(Attributes.ATTACK_KNOCKBACK, 0.0D) .add(Attributes.MOVEMENT_SPEED, 0.14D) .add(Attributes.FOLLOW_RANGE, 16.0D) .add(Attributes.MAX_HEALTH, 6.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0.0D); } public void registerGoals() { super.registerGoals(); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 2.0D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(2, new OpossumBackOffGoal<>(this, LivingEntity.class, 4, 1D, 1.1D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(3, new SmartWanderGoal(this, 1D, true)); this.goalSelector.addGoal(4, new RandomLookAroundGoal(this)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); this.targetSelector.addGoal(2, new HuntMobTarget<>(this, LivingEntity.class, true, 30, false, input -> getEcoLevel(input) <= getEcoLevel(this))); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.isInWater()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.003D, 0.0D)); if (!this.isNotMoving() && this.random.nextInt(5) == 0 && this.getDeltaMovement().horizontalDistance() > 0.08) { Vec3 testpos = this.position().add(Math.cos(Math.toRadians(this.getYRot()+ 90)) * -0.8, 0, Math.sin(Math.toRadians(this.getYRot() + 90)) * -0.8); BlockPos testblockpos = new BlockPos(testpos); if (level.getBlockState(new BlockPos(testblockpos.below())).is(BlockTags.MINEABLE_WITH_SHOVEL)) ((ServerLevel)this.level).sendParticles(new BlockParticleOption(ParticleTypes.FALLING_DUST, this.level.getBlockState(testblockpos.below())), testpos.x, testpos.y + 0.2, testpos.z, 2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, 0); else ((ServerLevel)this.level).sendParticles(ParticleTypes.UNDERWATER, testpos.x, testpos.y + 0.2, testpos.z, 2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, 0); } } if (this.isPlayingDead() && this.forceSleep == 0) { this.setPlayingDead(false); } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); if (this.getJoeys() > 0 && this.random.nextInt(2) == 0) { EntityOpossum child = this.getBreedOffspring((ServerLevel) this.level, this); if (child != null) { child.setVariant(this.getVariant()); child.setAge(this.getAdulthoodTime() * -1); child.setGender(this.random.nextInt(2)); child.setRandomMobSize(); child.setBaby(true); child.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); if (this.getOwner() != null) child.tame((Player) this.getOwner()); if (this instanceof INeedsPostUpdate) { ((INeedsPostUpdate) child).updateAttributes(); } if (TEXTURES_COMMON.containsKey(child.getType().getRegistryName().getPath())) { chooseSkinForSpecies(child, true); } //((ServerLevel)this.level).addFreshEntityWithPassengers(child); this.level.addFreshEntity(child); this.level.broadcastEntityEvent(this, (byte)18); this.setJoeys(this.getJoeys() - 1); } } } if (this.getAnimation() == NO_ANIMATION && this.getTarget() == null && !this.isSleeping()) { int i = this.random.nextInt(3000); if (i <= 8 && !this.isInWater()) { this.getNavigation().stop(); this.setSitting(true); } else if ((i <= 12 || this.isInWater()) && this.isSitting()) { this.setSitting(false); } else if (i > 2980) { this.setAnimation(IDLE_SCRATCH); } } if (this.getAnimation() == THREAT_BACK_OFF) { this.getMoveControl().strafe(-0.5F, 0); } } } /* Breeding conditions for the giant salamander are: * A nearby Opossum of the opposite gender and the same species */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getJoeys() == 0 && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityOpossum> list = this.level.getEntitiesOfClass(EntityOpossum.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); return list.size() >= 1; } } return false; } public <T extends ComplexMob> void breed() { this.setJoeys(this.random.nextInt(3) + 1); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (itemstack.isEmpty() && this.isAlive() && hand.equals(InteractionHand.MAIN_HAND)) { this.setAnimation(THREAT_BACK_OFF); return InteractionResult.sidedSuccess(this.level.isClientSide); } return super.mobInteract(player, hand); } @Nullable public EntityOpossum getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { return create_offspring(new EntityOpossum(ModEntity.OPOSSUM.get(), this.level)); } public boolean hurt(DamageSource damageSource, float amount) { if (!this.isPlayingDead()) { if (damageSource.getEntity() instanceof Mob aggressor) { // TODO: null target doesn't work aggressor.setTarget(null); this.makeAreaOfEffectCloud(this.level, this.blockPosition()); this.setPlayingDead(true); this.forceSleep = 600; } } return super.hurt(damageSource, amount); } public boolean canBeAffected(MobEffectInstance potionEffectIn) { return potionEffectIn.getEffect() != MobEffects.POISON && super.canBeAffected(potionEffectIn); } private void makeAreaOfEffectCloud(Level worldIn, BlockPos pos) { AreaEffectCloud linger_cloud = new AreaEffectCloud(worldIn, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); linger_cloud.setRadius(3.0F); linger_cloud.setRadiusOnUse(-0.2F); linger_cloud.setWaitTime(10); linger_cloud.setRadiusPerTick(-linger_cloud.getRadius() / ((float)linger_cloud.getDuration() * 0.2F)); linger_cloud.setFixedColor(5599028); linger_cloud.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 80, 0, true, false)); worldIn.addFreshEntity(linger_cloud); } public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, IDLE_SCRATCH, THREAT_BACK_OFF}; } public boolean canBeTargeted() { return !this.isPlayingDead(); } public boolean isPlayingDead(){ return (this.entityData.get(PLAYING_DEAD)); } private void setPlayingDead(boolean short_snout){ this.entityData.set(PLAYING_DEAD, short_snout); } public int getJoeys(){ return (this.entityData.get(JOEYS)); } private void setJoeys(int joeys){ this.entityData.set(JOEYS, joeys); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("playing_dead", this.isPlayingDead()); compound.putInt("joeys", this.getJoeys()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setPlayingDead(compound.getBoolean("playing_dead")); this.setJoeys(compound.getInt("joeys")); } public static class OpossumBackOffGoal<T extends LivingEntity> extends AvoidEntityGoal<T> { protected EntityOpossum taskOwner; protected final float avoidDistance; private final TargetingConditions builtTargetSelector; public OpossumBackOffGoal(EntityOpossum entityIn, Class<T> classToAvoidIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn, final Predicate<LivingEntity> targetSelector) { super(entityIn, classToAvoidIn, avoidDistanceIn, farSpeedIn, nearSpeedIn, EntitySelector.NO_CREATIVE_OR_SPECTATOR::test); this.taskOwner = entityIn; this.avoidDistance = avoidDistanceIn; this.builtTargetSelector = TargetingConditions.forCombat().range(avoidDistanceIn).selector(targetSelector); this.setFlags(EnumSet.of(Goal.Flag.MOVE)); } @Override public boolean canUse() { if (this.taskOwner.tickCount % 4 != 0) { return false; } if (this.taskOwner.getTarget() != null || this.taskOwner.isSleeping() || this.taskOwner.getCommandInt() != 0 || this.taskOwner.isTame()) { return false; } List<T> list = this.taskOwner.level.getNearbyEntities(avoidClass, this.builtTargetSelector, this.taskOwner, this.taskOwner.getBoundingBox().inflate(avoidDistance, 4f, avoidDistance)); if (list.isEmpty()) { return false; } else { this.toAvoid = list.get(0); return this.toAvoid != null; } } public boolean canContinueToUse() { return this.taskOwner.getAnimation() == NO_ANIMATION; } @Override public void start() { if (!this.taskOwner.getNavigation().isDone()) this.taskOwner.getNavigation().stop(); if (this.taskOwner.isSitting()) this.taskOwner.setSitting(false); this.taskOwner.playSound(ModSounds.ENTITY_OPOSSUM_HISS, 1.0F, this.taskOwner.getVoicePitch()); this.taskOwner.getLookControl().setLookAt(this.toAvoid); this.taskOwner.setAnimation(THREAT_BACK_OFF); } public void stop() { this.toAvoid = null; } public void tick() { if (this.taskOwner.getAnimation() == NO_ANIMATION) this.taskOwner.setAnimation(THREAT_BACK_OFF); this.taskOwner.lookAt(this.toAvoid, 30.0F, 30.0F);; } } }
14,060
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityBoar.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityBoar.java
package untamedwilds.entity.mammal; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.BlockTags; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal; import net.minecraft.world.entity.ai.util.DefaultRandomPos; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import untamedwilds.UntamedWilds; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.target.AngrySleeperTarget; import untamedwilds.entity.ai.target.SmartOwnerHurtTargetGoal; import untamedwilds.init.ModEntity; import untamedwilds.init.ModLootTables; import untamedwilds.init.ModSounds; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.EnumSet; import java.util.List; public class EntityBoar extends ComplexMobTerrestrial implements ISpecies, INewSkins, INeedsPostUpdate { private static final EntityDataAccessor<Boolean> WARTHOG = SynchedEntityData.defineId(EntityBoar.class, EntityDataSerializers.BOOLEAN); private BlockPos lastDugPos = null; public static Animation WORK_DIG; public static Animation ATTACK; public static Animation TALK; public EntityBoar(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.entityData.define(WARTHOG, false); this.turn_speed = 0.6F; WORK_DIG = Animation.create(48); ATTACK = Animation.create(18); TALK = Animation.create(20); } public void registerGoals() { this.goalSelector.addGoal(1, new SmartSwimGoal_Land(this)); this.goalSelector.addGoal(2, new GoHogWildGoal(this, 2D)); this.goalSelector.addGoal(2, new FindItemsGoal(this, 12, 100, false, true)); this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 2D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(2, new SmartAvoidGoal<>(this, LivingEntity.class, 16, 1.2D, 1.6D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(3, new GotoSleepGoal(this, 1)); this.goalSelector.addGoal(5, new SmartWanderGoal(this, 1D, 120, 20, true)); this.goalSelector.addGoal(6, new SmartLookAtGoal(this, LivingEntity.class, 10.0F)); this.targetSelector.addGoal(1, (new HurtByTargetGoal(this))); this.targetSelector.addGoal(4, new AngrySleeperTarget<>(this, LivingEntity.class, true)); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 3.0D) .add(Attributes.ATTACK_KNOCKBACK, 0.8D) .add(Attributes.MOVEMENT_SPEED, 0.2D) .add(Attributes.FOLLOW_RANGE, 24.0D) .add(Attributes.MAX_HEALTH, 16.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0.6D) .add(Attributes.ARMOR, 2D); } public boolean wantsToBreed() { if (super.wantsToBreed()) { return !this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this) && this.getHunger() >= 80; } return false; } @Override protected void reassessTameGoals() { if (this.isTame()) { if (UntamedWilds.DEBUG) { UntamedWilds.LOGGER.info("Updating AI tasks for tamed mob"); } this.goalSelector.addGoal(3, new SmartFollowOwnerGoal(this, 2.3D, 12.0F, 3.0F)); this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this)); this.targetSelector.addGoal(2, new SmartOwnerHurtTargetGoal(this)); } } @Override public void aiStep() { if (!this.level.isClientSide) { this.setAngry(this.getTarget() != null); if (this.level.getGameTime() % 1000 == 0) { this.addHunger(-10); if (!this.isStarving()) { this.heal(1.0F); } } // Random idle animations if (this.getAnimation() == NO_ANIMATION && this.getTarget() == null && !this.isSleeping() && this.getCommandInt() == 0) { int i = this.random.nextInt(3000); if (i == 13 && !this.isInWater() && this.isNotMoving() && this.canMove()) { this.setSitting(true); } if (i == 14 && this.isSitting()) { this.setSitting(false); } if (i > 2960 && i < 2979 && !this.isInWater() && !this.isBaby()) { this.setAnimation(TALK); } if (i > 2980 && !this.isInWater() && this.getHunger() < 60 && this.canMove() && this.getAnimation() == NO_ANIMATION) { if ((this.lastDugPos == null || this.distanceToSqr(this.lastDugPos.getX(), this.getY(), this.lastDugPos.getZ()) > 50) && this.level.getBlockState(this.blockPosition().below()).is(BlockTags.MINEABLE_WITH_SHOVEL)) { this.setAnimation(WORK_DIG); this.addHunger(20); this.lastDugPos = this.blockPosition(); } } } if (this.getAnimation() == WORK_DIG && this.getAnimationTick() % 8 == 0) { ((ServerLevel)this.level).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, this.level.getBlockState(this.blockPosition().below())), this.getX(), this.getY(), this.getZ(), 20, 0.0D, 0.0D, 0.0D, 0.15F); this.playSound(SoundEvents.SHOVEL_FLATTEN, 0.8F, 0.6F); if (this.getAnimationTick() == 64 && this.random.nextInt(5) == 0) { List<ItemStack> result = EntityUtils.getItemFromLootTable(ModLootTables.LOOT_DIGGING, this.level); for (ItemStack itemstack : result) this.spawnAtLocation(itemstack); } } if (this.getAnimation() == TALK && this.getAnimationTick() == 1 && this.getAmbientSound() != null) { this.playSound(this.getAmbientSound(), this.getSoundVolume(), this.getVoicePitch()); } if (this.getTarget() != null && this.tickCount % 120 == 0) { this.playSound(this.getThreatSound(), this.getSoundVolume(), this.getVoicePitch()); } if (this.getAnimation() != NO_ANIMATION) { if (this.getAnimation() == ATTACK && this.getAnimationTick() == 8 && this.random.nextInt(3) == 0) { this.playSound(ModSounds.ENTITY_BOAR_SQUEAL, this.getSoundVolume(), this.getVoicePitch()); } } } super.aiStep(); } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { if (!this.isTame() && this.isBaby() && EntityUtils.hasFullHealth(this) && this.isFood(itemstack)) { this.playSound(SoundEvents.HORSE_EAT, 1.5F, 0.8F); if (this.getRandom().nextInt(3) == 0) { this.tame(player); EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.HEART, 3, 6); } else { EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.SMOKE, 3, 3); } } if (!this.isTame() && !this.isBaby() && itemstack.isEmpty()) { this.setSitting(false); this.setSleeping(false); if (!this.level.isClientSide) { player.setYRot(this.getYRot()); player.setXRot(this.getXRot()); player.startRiding(this); } } } return super.mobInteract(player, hand); } @Override public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { this.setAnimation(ATTACK); this.setAnimationTick(0); } return flag; } public boolean hurt(DamageSource damageSource, float amount) { // Retaliate I: Mob will strike back when attacked by its current target performRetaliation(damageSource, this.getHealth(), amount, true); return super.hurt(damageSource, amount); } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, WORK_DIG, ATTACK, TALK}; } public Animation getAnimationEat() { return WORK_DIG; } @Nullable public EntityBoar getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { return create_offspring(new EntityBoar(ModEntity.BOAR.get(), this.level)); } @Override public void updateAttributes() { this.setWarthog(getEntityData(this.getType()).getFlags(this.getVariant(), "isWarthog") == 1); } public boolean isWarthog(){ return (this.entityData.get(WARTHOG)); } private void setWarthog(boolean warthog){ this.entityData.set(WARTHOG, warthog); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("isWarthog", this.isWarthog()); if (this.lastDugPos != null) { compound.putInt("DugPosX", this.lastDugPos.getX()); compound.putInt("DugPosZ", this.lastDugPos.getZ()); } } public void readAdditionalSaveData(CompoundTag compound) { super.readAdditionalSaveData(compound); this.setWarthog(compound.getBoolean("isWarthog")); if (compound.contains("LastDugPos")) { this.lastDugPos = new BlockPos(compound.getInt("DugPosX"), 0, compound.getInt("DugPosZ")); } } public static class GoHogWildGoal extends Goal { private final EntityBoar boar; private final double speedModifier; private double posX; private double posY; private double posZ; public GoHogWildGoal(EntityBoar p_25890_, double p_25891_) { this.boar = p_25890_; this.speedModifier = p_25891_; this.setFlags(EnumSet.of(Goal.Flag.MOVE)); } public boolean canUse() { if (!this.boar.isTame() && this.boar.isVehicle()) { Vec3 vec3 = DefaultRandomPos.getPos(this.boar, 5, 4); if (vec3 == null) { return false; } else { this.posX = vec3.x; this.posY = vec3.y; this.posZ = vec3.z; return true; } } else { return false; } } public void start() { this.boar.getNavigation().moveTo(this.posX, this.posY, this.posZ, this.speedModifier); } public boolean canContinueToUse() { return !this.boar.isTame() && !this.boar.getNavigation().isDone() && this.boar.isVehicle(); } public void tick() { if (this.boar.getRandom().nextInt(this.adjustedTickDelay(50)) < 3) { this.boar.setAnimation(ATTACK); this.boar.playSound(ModSounds.ENTITY_BOAR_SQUEAL, this.boar.getSoundVolume(), this.boar.getVoicePitch()); } if (!this.boar.isTame() && this.boar.getRandom().nextInt(this.adjustedTickDelay(50)) == 0) { Entity entity = this.boar.getPassengers().get(0); if (entity == null) { return; } this.boar.ejectPassengers(); this.boar.setTarget((LivingEntity) entity); this.boar.level.broadcastEntityEvent(this.boar, (byte)6); } } } }
13,112
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityHippo.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityHippo.java
package untamedwilds.entity.mammal; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.level.Level; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.ComplexMobAmphibious; import untamedwilds.entity.INewSkins; import untamedwilds.entity.ISpecies; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.unique.HippoTerritoryTargetGoal; import untamedwilds.init.ModEntity; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; public class EntityHippo extends ComplexMobAmphibious implements INewSkins, ISpecies { public static Animation EAT; public static Animation IDLE_YAWN; public static Animation IDLE_LOOK; public static Animation ATTACK; public static Animation IDLE_TALK; public int angryProgress; public EntityHippo(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); IDLE_YAWN = Animation.create(36); IDLE_LOOK = Animation.create(128); IDLE_TALK = Animation.create(20); EAT = Animation.create(48); ATTACK = Animation.create(24); this.maxUpStep = 1F; this.isAmphibious = true; this.turn_speed = 0.3F; } public void registerGoals() { this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 1.4D, false)); this.goalSelector.addGoal(3, new SmartMateGoal(this, 0.8D)); this.goalSelector.addGoal(3, new GrazeGoal(this, 10)); this.goalSelector.addGoal(4, new AmphibiousTransition(this, 1.1D)); this.goalSelector.addGoal(4, new GotoSleepGoal(this, 1D)); this.goalSelector.addGoal(5, new SmartWanderGoal(this, 1D, 120, 0, false)); this.goalSelector.addGoal(5, new AmphibiousRandomSwimGoal(this, 1, 120)); this.goalSelector.addGoal(6, new SmartLookAtGoal(this, LivingEntity.class, 10.0F)); this.targetSelector.addGoal(1, (new HurtByTargetGoal(this)).setAlertOthers()); this.targetSelector.addGoal(3, new HippoTerritoryTargetGoal<>(this, LivingEntity.class, true, false, input -> !(input instanceof EntityHippo || input instanceof ISpecies || getEcoLevel(input) > getEcoLevel(this)))); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 9.0D) .add(Attributes.ATTACK_KNOCKBACK, 1.6D) .add(Attributes.MOVEMENT_SPEED, 0.8D) .add(Attributes.FOLLOW_RANGE, 24.0D) .add(Attributes.MAX_HEALTH, 60.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 1D) .add(Attributes.ARMOR, 0D); } public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.age == 0) { return this.getHunger() >= 80; } return false; } @Override public void aiStep() { if (!this.level.isClientSide) { if (this.isInWater() && this.getTarget() == null) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.01D, 0.0D)); } if (this.level.getGameTime() % 1000 == 0) { this.addHunger(-10); if (!this.isStarving()) { this.heal(1.0F); } } int i = this.random.nextInt(3000); if (i <= 8 && !this.isInWater() && !this.isAngry() && !this.isSleeping() && this.getAnimation() == NO_ANIMATION) { this.setAnimation(IDLE_YAWN); } if ((i > 8 && i <= 12) && !this.isAngry() && !this.isSleeping() && this.getAnimation() == NO_ANIMATION) { this.setAnimation(IDLE_LOOK); } if (i == 13 && !this.isInWater() && this.isNotMoving() && this.canMove() && this.getAnimation() == NO_ANIMATION) { this.setSitting(true); } if (i == 14 && this.isSitting()) { this.setSitting(false); } if (i == 15 && !this.isActive() && !this.isSleeping() && this.isInWater()){ this.setAnimation(IDLE_YAWN); this.setSleeping(true); this.forceSleep = -800 - this.random.nextInt(1200); } if (i > 2980 && !this.isBaby()) { this.setAnimation(IDLE_TALK); } if (this.getAnimation() == ATTACK && this.getTarget() != null && this.getBoundingBox().inflate(1.2F, 1.0F, 1.2F).contains(this.getTarget().getPosition(0)) && (this.getAnimationTick() > 8)) { LivingEntity target = this.getTarget(); this.getTarget().hurt(DamageSource.mobAttack(this), (float) this.getAttribute(Attributes.ATTACK_DAMAGE).getValue()); EntityUtils.destroyBoat(this.level, target); } this.setAngry(this.getTarget() != null); } if (this.getAnimation() != NO_ANIMATION) { if (this.getAnimation() == IDLE_TALK && this.getAnimationTick() == 1 && this.getAmbientSound() != null) { this.playSound(this.getAmbientSound(), this.getSoundVolume(), this.getVoicePitch()); } } if (this.level.isClientSide && this.isAngry() && this.angryProgress < 40) { this.angryProgress += 4; } else if (this.level.isClientSide && !this.isAngry() && this.angryProgress > 0) { this.angryProgress -= 4; } super.aiStep(); } @Override public boolean wantsToBeOnLand(){ return this.isActive(); } @Override public boolean wantsToBeInWater(){ return !this.isActive(); } public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { Animation anim = chooseAttackAnimation(); this.setAnimation(anim); } return flag; } public boolean hurt(DamageSource damageSource, float amount) { // Retaliate I: Mob will strike back when attacked by its current target performRetaliation(damageSource, this.getHealth(), amount, true); return super.hurt(damageSource, amount); } private Animation chooseAttackAnimation() { return ATTACK; } @Nullable public EntityHippo getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { return create_offspring(new EntityHippo(ModEntity.HIPPO.get(), this.level)); } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, EAT, IDLE_YAWN, IDLE_LOOK, IDLE_TALK, ATTACK}; } public Animation getAnimationEat() { return EAT; } }
7,270
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityBaleenWhale.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityBaleenWhale.java
package untamedwilds.entity.mammal; import com.mojang.math.Vector3d; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.BreathAirGoal; import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraftforge.entity.PartEntity; import untamedwilds.entity.*; import untamedwilds.entity.ai.SmartMateGoal; import untamedwilds.entity.ai.unique.BaleenWhaleFeedGoal; import untamedwilds.entity.ai.unique.WhaleBreachGoal; import untamedwilds.entity.ai.unique.WhaleSwimmingGoal; import untamedwilds.init.ModEntity; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityBaleenWhale extends ComplexMobAquatic implements ISpecies, INewSkins, INeedsPostUpdate { private static final EntityDataAccessor<Boolean> IS_EATING = SynchedEntityData.defineId(EntityBaleenWhale.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor<Boolean> LONG_FINS = SynchedEntityData.defineId(EntityBaleenWhale.class, EntityDataSerializers.BOOLEAN); public int length; public EntityWhalePart[] whale_parts; public int ringBufferIndex = -1; public final double[][] ringBuffer = new double[64][3]; public int gulpProgress; public EntityBaleenWhale(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.entityData.define(LONG_FINS, false); this.length = getMultiparts(); this.whale_parts = new EntityWhalePart[this.length]; for (int i = 0; i < this.length; i++) { this.whale_parts[i] = new EntityWhalePart(this, this.getBbWidth(), this.getBbHeight()); } this.turn_speed = 0.03F; } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(IS_EATING, false); } private void setPartPosition(EntityWhalePart part, double offsetX, double offsetY, double offsetZ) { part.setPos(this.getX() + offsetX * part.scale, this.getY() + offsetY * part.scale, this.getZ() + offsetZ * part.scale); } @Override public boolean isMultipartEntity() { return true; } @Override public PartEntity<?>[] getParts() { return this.whale_parts; } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 3.0D) .add(Attributes.ATTACK_KNOCKBACK, 1.6D) .add(Attributes.MOVEMENT_SPEED, 0.8D) .add(Attributes.FOLLOW_RANGE, 12.0D) .add(Attributes.MAX_HEALTH, 100.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 1D) .add(Attributes.ARMOR, 6D); } public void registerGoals() { //super.registerGoals(); this.goalSelector.addGoal(0, new BreathAirGoal(this)); this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.3D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(4, new WhaleSwimmingGoal(this)); this.goalSelector.addGoal(5, new WhaleBreachGoal(this, 10)); this.goalSelector.addGoal(5, new BaleenWhaleFeedGoal(this, 400)); this.targetSelector.addGoal(3, new HurtByTargetGoal(this)); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } if (!this.isNoAi() && !this.isBaby()) { if (this.ringBufferIndex < 0) { for (int i = 0; i < this.ringBuffer.length; ++i) { this.ringBuffer[i][0] = this.getYRot(); this.ringBuffer[i][1] = this.getY(); } } this.ringBufferIndex++; if (this.ringBufferIndex == this.ringBuffer.length) { this.ringBufferIndex = 0; } // Just replaced the contents of Mth.interpolateAngle with the returned formula. Why even is this shit @OnlyIn(Client)??? this.ringBuffer[this.ringBufferIndex][0] = this.yRotO + 0.5F * Mth.wrapDegrees(this.getYRot() - this.yRotO); this.ringBuffer[ringBufferIndex][1] = this.getY(); Vector3d[] avector3d = new Vector3d[this.whale_parts.length]; for (int j = 0; j < this.whale_parts.length; ++j) { this.whale_parts[j].collideWithNearbyEntities(); avector3d[j] = new Vector3d(this.whale_parts[j].getX(), this.whale_parts[j].getY(), this.whale_parts[j].getZ()); } float f15 = (float) (this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F * ((float) Math.PI / 180F); float f16 = Mth.cos(f15); float yaw = this.getYRot() * ((float) Math.PI / 180F); float pitch = this.getXRot() * ((float) Math.PI / 180F); float f3 = Mth.sin(yaw) * (1 - Math.abs(this.getXRot() / 90F)); float f18 = Mth.cos(yaw) * (1 - Math.abs(this.getXRot() / 90F)); double[] adouble = this.getMovementOffsets(5, 1.0F); float var = 1; for (int k = 0; k < getMultiparts(); ++k) { EntityWhalePart whale_part = this.whale_parts[k]; double[] adouble1 = this.getMovementOffsets(5 + k * 2, 1.0F); float f7 = yaw + (float) Mth.wrapDegrees(adouble1[0] - adouble[0]) * ((float) Math.PI / 180F); float f20 = Mth.sin(f7) * (1 - Math.abs(this.getXRot() / 90F)); float f21 = Mth.cos(f7) * (1 - Math.abs(this.getXRot() / 90F)); float offset = k % 2 == 0 ? -1 : 1; if (k % 2 == 0) { var++; } float f23 = var * 1.5F * offset; float value = Mth.clamp(pitch * k, (float)Math.toRadians(-40), (float)Math.toRadians(40)); this.setPartPosition(whale_part, -(f3 * 0.5 + f20 * f23) * f16, value * -offset, (f18 * 0.5 + f21 * f23) * f16); this.whale_parts[k].xo = avector3d[k].x; this.whale_parts[k].yo = avector3d[k].y; this.whale_parts[k].zo = avector3d[k].z; this.whale_parts[k].xOld = avector3d[k].x; this.whale_parts[k].yOld = avector3d[k].y; this.whale_parts[k].zOld = avector3d[k].z; } } if (this.level.isClientSide && this.isFeeding() && this.gulpProgress < 50) { this.gulpProgress += 1; } else if (this.level.isClientSide && !this.isFeeding() && this.gulpProgress > 0) { this.gulpProgress -= 1; } } @Override protected SoundEvent getFlopSound() { return SoundEvents.GUARDIAN_FLOP; } public double[] getMovementOffsets(int offset, float partialTicks) { if (this.isDeadOrDying()) { partialTicks = 0.0F; } partialTicks = 1.0F - partialTicks; int i = this.ringBufferIndex - offset & 63; int j = this.ringBufferIndex - offset - 1 & 63; double[] adouble = new double[3]; double d0 = this.ringBuffer[i][0]; double d1 = this.ringBuffer[j][0] - d0; adouble[0] = d0 + d1 * (double) partialTicks; d0 = this.ringBuffer[i][1]; d1 = this.ringBuffer[j][1] - d0; adouble[1] = d0 + d1 * (double) partialTicks; adouble[2] = Mth.lerp(0.5F, this.ringBuffer[i][2], this.ringBuffer[j][2]); return adouble; } /* Breeding conditions for the Whale are: * A nearby Whale of the opposite gender and the same species */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityBaleenWhale> list = this.level.getEntitiesOfClass(EntityBaleenWhale.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } } return false; } public boolean hasLongFins(){ return (this.entityData.get(LONG_FINS)); } private void setLongFins(boolean long_fins){ this.entityData.set(LONG_FINS, long_fins); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("hasLongFins", this.hasLongFins()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setLongFins(compound.getBoolean("hasLongFins")); } @Override public void updateAttributes() { //this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getAttack()); //this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getHealth()); this.setHealth(this.getMaxHealth()); this.length = getMultiparts(); this.whale_parts = new EntityWhalePart[this.length]; for (int i = 0; i < this.length; i++) { this.whale_parts[i] = new EntityWhalePart(this, this.getBbWidth(), this.getBbHeight()); } this.setLongFins(getEntityData(this.getType()).getFlags(this.getVariant(), "hasLongFins") == 1); } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { return create_offspring(new EntityBaleenWhale(ModEntity.BALEEN_WHALE.get(), this.level)); } public boolean attackEntityPartFrom(EntityWhalePart whale_part, DamageSource source, float amount) { return this.hurt(source, amount); } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { if (itemstack.getItem() == Items.BLAZE_ROD) { this.setFeeding(!this.isFeeding()); } } return super.mobInteract(player, hand); } // Flags Parameters public int getMultiparts() { return 3 + (int)((this.getModelScale() - 1) * 4); } public boolean canBeTargeted() { return false; } public boolean isFeeding() { return entityData.get(IS_EATING); } public void setFeeding(boolean bool) { entityData.set(IS_EATING, bool); } public static class EntityWhalePart extends PartEntity<EntityBaleenWhale> { private final EntityDimensions size; public float scale = 1; public EntityWhalePart(EntityBaleenWhale parent, float sizeX, float sizeY) { super(parent); this.size = EntityDimensions.scalable(sizeX, sizeY); this.refreshDimensions(); } protected void collideWithNearbyEntities() { List<Entity> entities = this.level.getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)); Entity parent = this.getParent(); if (parent != null) { entities.stream().filter(entity -> entity != parent && !(entity instanceof EntityWhalePart && ((EntityWhalePart) entity).getParent() == parent) && entity.isPushable()).forEach(entity -> entity.push(parent)); } } public InteractionResult mobInteract(Player player, InteractionHand hand) { return this.getParent() == null ? InteractionResult.PASS : this.getParent().mobInteract(player, hand); } public void push(Entity entityIn) { entityIn.push(this); } public boolean canBeCollidedWith() { return true; } public boolean hurt(DamageSource source, float amount) { return !this.isInvulnerableTo(source) && this.getParent().attackEntityPartFrom(this, source, amount); } @Override protected void defineSynchedData() { } @Override protected void readAdditionalSaveData(CompoundTag compound) { } @Override protected void addAdditionalSaveData(CompoundTag compound) { } public boolean is(Entity entityIn) { return this == entityIn || this.getParent() == entityIn; } public Packet<?> getAddEntityPacket() { throw new UnsupportedOperationException(); } public EntityDimensions getSize(Pose poseIn) { return this.size.scale(scale); } } }
13,828
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityAardvark.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityAardvark.java
package untamedwilds.entity.mammal; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.BlockTags; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.ComplexMobTerrestrial; import untamedwilds.entity.INewSkins; import untamedwilds.entity.ISpecies; import untamedwilds.entity.ai.*; import untamedwilds.init.ModEntity; import untamedwilds.init.ModItems; import untamedwilds.init.ModLootTables; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityAardvark extends ComplexMobTerrestrial implements ISpecies, INewSkins { private BlockPos lastDugPos = null; public static Animation WORK_DIG; public static Animation ATTACK; public EntityAardvark(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.turn_speed = 0.8F; WORK_DIG = Animation.create(76); ATTACK = Animation.create(18); } public void registerGoals() { this.goalSelector.addGoal(1, new SmartSwimGoal_Land(this)); this.goalSelector.addGoal(2, new FindItemsGoal(this, 12, 100, false, true)); this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.6D, false)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(2, new SmartAvoidGoal<>(this, LivingEntity.class, 16, 1.2D, 1.6D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(3, new GotoSleepGoal(this, 1)); this.goalSelector.addGoal(5, new SmartWanderGoal(this, 1D, 120, 0, false)); this.goalSelector.addGoal(6, new SmartLookAtGoal(this, LivingEntity.class, 10.0F)); this.targetSelector.addGoal(1, (new HurtByTargetGoal(this))); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 1.0D) .add(Attributes.ATTACK_KNOCKBACK, 0.1D) .add(Attributes.MOVEMENT_SPEED, 0.18D) .add(Attributes.FOLLOW_RANGE, 24.0D) .add(Attributes.MAX_HEALTH, 8.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0D) .add(Attributes.ARMOR, 0D); } public boolean wantsToBreed() { if (super.wantsToBreed()) { return !this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this) && this.getHunger() >= 80; } return false; } @Override public void aiStep() { if (!this.level.isClientSide) { this.setAngry(this.getTarget() != null); if (this.level.getGameTime() % 1000 == 0) { this.addHunger(-10); if (!this.isStarving()) { this.heal(1.0F); } } // Random idle animations if (this.getAnimation() == NO_ANIMATION && this.getTarget() == null && !this.isSleeping() && this.getCommandInt() == 0) { int i = this.random.nextInt(3000); if (i == 13 && !this.isInWater() && this.isNotMoving() && this.canMove()) { this.setSitting(true); } if (i == 14 && this.isSitting()) { this.setSitting(false); } if (i > 2980 && !this.isInWater() && this.getHunger() < 60 && this.canMove() && this.getAnimation() == NO_ANIMATION) { if ((this.lastDugPos == null || this.distanceToSqr(this.lastDugPos.getX(), this.getY(), this.lastDugPos.getZ()) > 50) && this.level.getBlockState(this.blockPosition().below()).is(BlockTags.MINEABLE_WITH_SHOVEL)) { this.setAnimation(WORK_DIG); this.lastDugPos = this.blockPosition(); } } } if (this.getAnimation() == WORK_DIG && this.getAnimationTick() % 8 == 0) { ((ServerLevel)this.level).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, this.level.getBlockState(this.blockPosition().below())), this.getX(), this.getY(), this.getZ(), 20, 0.0D, 0.0D, 0.0D, 0.15F); this.playSound(SoundEvents.SHOVEL_FLATTEN, 0.8F, 0.6F); if (this.getAnimationTick() == 64) { int rand = this.random.nextInt(6); if (rand == 0) { List<ItemStack> result = EntityUtils.getItemFromLootTable(ModLootTables.LOOT_DIGGING, this.level); for (ItemStack itemstack : result) this.spawnAtLocation(itemstack); } else if (rand == 1) { this.spawnAtLocation(new ItemStack(ModItems.VEGETABLE_AARDVARK_CUCUMBER.get())); } } } } if (this.getAnimation() != NO_ANIMATION) { if (this.getAnimation() == ATTACK && (this.getAnimationTick() == 8 || this.getAnimationTick() == 12)) { this.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, 1.0F, 0.7F); } } super.aiStep(); } protected float getStandingEyeHeight(Pose poseIn, EntityDimensions sizeIn) { return sizeIn.height * 0.85F; } @Override public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { this.setAnimation(ATTACK); this.setAnimationTick(0); } return flag; } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, WORK_DIG, ATTACK}; } @Nullable public EntityAardvark getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { return create_offspring(new EntityAardvark(ModEntity.AARDVARK.get(), this.level)); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); if (this.lastDugPos != null) { compound.putInt("DugPosX", this.lastDugPos.getX()); compound.putInt("DugPosZ", this.lastDugPos.getZ()); } } public void readAdditionalSaveData(CompoundTag compound) { super.readAdditionalSaveData(compound); if (compound.contains("LastDugPos")) { this.lastDugPos = new BlockPos(compound.getInt("DugPosX"), 0, compound.getInt("DugPosZ")); } } }
7,160
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityManatee.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityManatee.java
package untamedwilds.entity.mammal; import net.minecraft.core.BlockPos; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.control.SmoothSwimmingMoveControl; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.goal.PanicGoal; import net.minecraft.world.level.Level; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.SmartMateGoal; import untamedwilds.entity.ai.control.look.SmartSwimmerLookControl; import untamedwilds.init.ModEntity; import untamedwilds.init.ModTags; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityManatee extends ComplexMobAquatic implements ISpecies, INewSkins, INeedsPostUpdate { private static final EntityDataAccessor<Boolean> IS_EATING = SynchedEntityData.defineId(EntityManatee.class, EntityDataSerializers.BOOLEAN); public int ringBufferIndex = -1; public final double[][] ringBuffer = new double[64][3]; public EntityManatee(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.entityData.define(IS_EATING, false); this.moveControl = new SmoothSwimmingMoveControl(this, 30, 10, 0.02F, 0.1F, true); this.lookControl = new SmartSwimmerLookControl(this, 30); this.turn_speed = 0.1F; } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 2.0D) .add(Attributes.ATTACK_KNOCKBACK, 0D) .add(Attributes.MOVEMENT_SPEED, 0.45D) .add(Attributes.FOLLOW_RANGE, 8.0D) .add(Attributes.MAX_HEALTH, 30.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 1D) .add(Attributes.ARMOR, 2D); } protected void registerGoals() { //super.registerGoals(); this.goalSelector.addGoal(0, new PanicGoal(this, 1.25D)); this.goalSelector.addGoal(2, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(3, new ManateeFeedGoal(this, 120)); this.goalSelector.addGoal(4, new SwimGoal(this)); } public void aiStep() { super.aiStep(); if (!this.level.isClientSide) { if (this.isEating()) { this.setDeltaMovement(this.getDeltaMovement().add(0, -0.01F, 0)); } if (this.level.getGameTime() % 4000 == 0) { this.heal(1.0F); } } if (!this.isNoAi() && !this.isBaby()) { if (this.ringBufferIndex < 0) { for (int i = 0; i < this.ringBuffer.length; ++i) { this.ringBuffer[i][0] = this.getYRot(); this.ringBuffer[i][1] = this.getY(); } } this.ringBufferIndex++; if (this.ringBufferIndex == this.ringBuffer.length) { this.ringBufferIndex = 0; } this.ringBuffer[this.ringBufferIndex][0] = this.yRotO + 0.5F * Mth.wrapDegrees(this.getYRot() - this.yRotO); this.ringBuffer[ringBufferIndex][1] = this.getY(); } } public double[] getMovementOffsets(int offset, float partialTicks) { if (this.isDeadOrDying()) { partialTicks = 0.0F; } partialTicks = 1.0F - partialTicks; int i = this.ringBufferIndex - offset & 63; int j = this.ringBufferIndex - offset - 1 & 63; double[] adouble = new double[3]; double d0 = this.ringBuffer[i][0]; double d1 = this.ringBuffer[j][0] - d0; adouble[0] = d0 + d1 * (double) partialTicks; d0 = this.ringBuffer[i][1]; d1 = this.ringBuffer[j][1] - d0; adouble[1] = d0 + d1 * (double) partialTicks; adouble[2] = Mth.lerp(partialTicks, this.ringBuffer[i][2], this.ringBuffer[j][2]); return adouble; } /* Breeding conditions for the Manatee are: * A nearby Manatee */ public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityManatee> list = this.level.getEntitiesOfClass(EntityManatee.class, this.getBoundingBox().inflate(12.0D, 8.0D, 12.0D)); list.removeIf(input -> EntityUtils.isInvalidPartner(this, input, false)); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { return create_offspring(new EntityManatee(ModEntity.MANATEE.get(), this.level)); } @Override protected SoundEvent getFlopSound() { return SoundEvents.GUARDIAN_FLOP; } @Override public void updateAttributes() { this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getAttack()); this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getHealth()); this.setHealth(this.getMaxHealth()); } public boolean isEating(){ return (this.entityData.get(IS_EATING)); } private void setIsEating(boolean eating){ this.entityData.set(IS_EATING, eating); } public class ManateeFeedGoal extends Goal { private final EntityManatee taskOwner; private final int chance; private BlockPos targetPos; private boolean taskComplete; private int counter; private int eatingCounter; public ManateeFeedGoal(EntityManatee entityIn, int chance) { this.taskOwner = entityIn; this.chance = chance; } public boolean canUse() { if (this.taskOwner.getRandom().nextInt(this.chance) == 0) { this.taskComplete = false; this.targetPos = getNearbySandBlock(this.taskOwner.blockPosition()); return this.targetPos != null; } return false; } private BlockPos getNearbySandBlock(BlockPos roomCenter) { int X = 5; int Y = 8; //List<BlockPos> inventories = new ArrayList<>(); for (BlockPos blockpos : BlockPos.MutableBlockPos.betweenClosed(roomCenter.offset(-X, -Y, -X), roomCenter.offset(X, 0, X))) { if (this.taskOwner.level.getBlockState(blockpos).is(ModTags.ModBlockTags.GRAZEABLE_ALGAE) && random.nextInt(2) == 0) { return blockpos; } } return null; } public boolean canContinueToUse() { return !this.taskComplete && !this.taskOwner.getNavigation().isDone() && this.eatingCounter != 0; } public void start() { this.eatingCounter = -1; this.taskOwner.getNavigation().moveTo(this.targetPos.getX() + 0.5, this.targetPos.above().getY(), this.targetPos.getZ() + 0.5, 1.5); } public void stop() { if (this.taskOwner.isEating()) this.taskOwner.setIsEating(false); super.stop(); } public void tick() { if (this.eatingCounter > 0) this.eatingCounter--; if (this.counter == 0 && this.taskOwner.distanceToSqr(this.targetPos.getX() + 0.5, this.targetPos.above().getY(), this.targetPos.getZ() + 0.5) < 1) { this.taskOwner.getNavigation().stop(); this.counter = this.taskOwner.getRandom().nextInt(20) + 30; } if (this.counter > 0) { this.counter--; if (this.counter == 0) { this.taskOwner.setIsEating(true); this.eatingCounter = this.taskOwner.getRandom().nextInt(40) + 20; this.taskOwner.getNavigation().stop(); Level worldIn = this.taskOwner.getLevel(); this.taskOwner.getLookControl().setLookAt(this.targetPos.getX(), this.targetPos.getY(), this.targetPos.getZ()); if (worldIn.getBlockState(this.targetPos).is(ModTags.ModBlockTags.GRAZEABLE_ALGAE)) { if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(worldIn, this.taskOwner)) { //worldIn.globalLevelEvent(2001, this.targetPos, Block.getId(Blocks.SEAGRASS.defaultBlockState())); if (ConfigGamerules.grazerGriefing.get()) { worldIn.destroyBlock(this.targetPos, false); } } } this.taskOwner.ate(); this.taskOwner.playSound(SoundEvents.GENERIC_EAT, 1F, 1); this.taskComplete = true; } } } } }
9,756
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityCamel.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityCamel.java
package untamedwilds.entity.mammal; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import untamedwilds.UntamedWilds; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.target.BeAnAssTarget; import untamedwilds.entity.ai.target.ProtectChildrenTarget; import untamedwilds.entity.ai.target.SmartOwnerHurtTargetGoal; import untamedwilds.init.ModEntity; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; public class EntityCamel extends ComplexMobTerrestrial implements INewSkins, ISpecies, IPackEntity { public static Animation IDLE_TALK; public static Animation ATTACK_SPIT; public EntityCamel(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); IDLE_TALK = Animation.create(20); ATTACK_SPIT = Animation.create(20); this.maxUpStep = 1F; this.turn_speed = 0.2F; } protected void defineSynchedData() { super.defineSynchedData(); } public void registerGoals() { this.goalSelector.addGoal(1, new SmartSwimGoal_Land(this)); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 1.6D, false)); //this.goalSelector.addGoal(2, new RangedAttackGoal(this, 1.25D, 40, 20.0F)); this.goalSelector.addGoal(3, new SmartMateGoal(this, 0.8D)); this.goalSelector.addGoal(3, new GrazeGoal(this, 10)); this.goalSelector.addGoal(4, new GotoSleepGoal(this, 1D)); this.goalSelector.addGoal(5, new SmartWanderGoal(this, 1D, 120, 0, true)); this.goalSelector.addGoal(6, new SmartLookAtGoal(this, LivingEntity.class, 10.0F)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); this.targetSelector.addGoal(2, new ProtectChildrenTarget<>(this, LivingEntity.class, true, input -> !(input instanceof EntityCamel) && getEcoLevel(input) > getEcoLevel(this))); this.targetSelector.addGoal(3, new BeAnAssTarget<>(this, LivingEntity.class, true, input -> !(input instanceof EntityCamel) && (getEcoLevel(input) < getEcoLevel(this)/2 || input instanceof Player))); } @Override protected void reassessTameGoals() { if (this.isTame()) { if (UntamedWilds.DEBUG) { UntamedWilds.LOGGER.info("Updating AI tasks for tamed mob"); } this.goalSelector.addGoal(3, new SmartFollowOwnerGoal(this, 1.3D, 12.0F, 3.0F)); this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this)); this.targetSelector.addGoal(2, new SmartOwnerHurtTargetGoal(this)); } } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 7.0D) .add(Attributes.ATTACK_KNOCKBACK, 1.5D) .add(Attributes.MOVEMENT_SPEED, 0.2D) .add(Attributes.FOLLOW_RANGE, 12.0D) .add(Attributes.MAX_HEALTH, 35.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 1D) .add(Attributes.ARMOR, 2D); } public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.age == 0) { return this.getHunger() >= 80; } return false; } @Override public void aiStep() { if (!this.level.isClientSide) { if (this.herd == null) { IPackEntity.initPack(this); } else { this.herd.tick(); } if (this.level.getGameTime() % 1000 == 0) { this.addHunger(-10); if (!this.isStarving()) { this.heal(1.0F); } } int i = this.random.nextInt(3000); if (i == 13 && !this.isInWater() && this.getTarget() == null && this.isNotMoving() && this.canMove() && this.getAnimation() == NO_ANIMATION) { this.setSitting(true); } if (i == 14 && this.isSitting()) { this.setSitting(false); } if (i > 2980 && !this.isBaby()) { this.setAnimation(IDLE_TALK); } if (this.getAnimation() == IDLE_TALK && this.getAnimationTick() == 1 && this.getAmbientSound() != null) { this.playSound(this.getAmbientSound(), this.getSoundVolume(), this.getVoicePitch()); } } super.aiStep(); } public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { Animation anim = chooseAttackAnimation(); this.setAnimation(anim); } return flag; } public boolean hurt(DamageSource p_19946_, float p_19947_) { if (p_19946_.equals(DamageSource.CACTUS)) { return false; } return super.hurt(p_19946_, p_19947_); } private Animation chooseAttackAnimation() { return NO_ANIMATION; } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.RAVAGER_STEP, 0.15F, 1.0F); } @Nullable public EntityCamel getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { return create_offspring(new EntityCamel(ModEntity.CAMEL.get(), this.level)); } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { if (!this.isTame() && this.isBaby() && EntityUtils.hasFullHealth(this) && this.isFood(itemstack)) { this.playSound(SoundEvents.HORSE_EAT, 1.5F, 0.8F); if (this.getRandom().nextInt(3) == 0) { this.tame(player); EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.HEART, 3, 6); } else { EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.SMOKE, 3, 3); } } } return super.mobInteract(player, hand); } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, IDLE_TALK, ATTACK_SPIT}; } public Animation getAnimationEat() { return NO_ANIMATION; } public void performRangedAttack(LivingEntity entityIn, float p_33318_) { ProjectileSpit camel_spit = new ProjectileSpit(this.level, this, new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); if (this.getAnimation() == NO_ANIMATION) this.setAnimation(ATTACK_SPIT); double d0 = entityIn.getX() - this.getX(); double d1 = entityIn.getY(0.3333333333333333D) - camel_spit.getY(); double d2 = entityIn.getZ() - this.getZ(); double d3 = Math.sqrt(d0 * d0 + d2 * d2) * (double)0.2F; camel_spit.shoot(d0, d1 + d3, d2, 1.5F, 10.0F); if (!this.isSilent()) { this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.LLAMA_SPIT, this.getSoundSource(), 1.0F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F); } this.level.addFreshEntity(camel_spit); } }
8,427
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityBear.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityBear.java
package untamedwilds.entity.mammal; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.ServerLevelAccessor; import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.NotNull; import untamedwilds.UntamedWilds; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.target.*; import untamedwilds.init.ModEntity; import untamedwilds.init.ModSounds; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityBear extends ComplexMobTerrestrial implements ISpecies, INewSkins, INeedsPostUpdate { private static final EntityDataAccessor<Boolean> SHORT_SNOUT = SynchedEntityData.defineId(EntityBear.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor<Boolean> BACK_HUMP = SynchedEntityData.defineId(EntityBear.class, EntityDataSerializers.BOOLEAN); public static Animation ATTACK_BITE; public static Animation ATTACK_MAUL; public static Animation ATTACK_SWIPE; public static Animation ATTACK_POUND; public static Animation ANIMATION_ROAR; public static Animation IDLE_STAND; public static Animation IDLE_TALK; public static Animation ANIMATION_EAT; public EntityBear(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.entityData.define(SHORT_SNOUT, false); this.entityData.define(BACK_HUMP, false); ANIMATION_ROAR = Animation.create(50); IDLE_TALK = Animation.create(20); IDLE_STAND = Animation.create(148); ANIMATION_EAT = Animation.create(104); ATTACK_BITE = Animation.create(18); ATTACK_MAUL = Animation.create(76); ATTACK_SWIPE = Animation.create(26); ATTACK_POUND = Animation.create(28); this.maxUpStep = 1; this.turn_speed = 0.3F; } public void registerGoals() { this.goalSelector.addGoal(1, new SmartSwimGoal_Land(this)); this.goalSelector.addGoal(2, new FindItemsGoal(this, 12)); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 2.3D, false, 1)); this.goalSelector.addGoal(3, new SmartAvoidGoal<>(this, LivingEntity.class, 16, 1.2D, 1.6D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(4, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(4, new GotoSleepGoal(this, 1D)); this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25D)); //this.goalSelector.addGoal(5, new BearRaidChestsGoal(this, 120)); this.goalSelector.addGoal(6, new SmartWanderGoal(this, 1D, true)); this.goalSelector.addGoal(7, new SmartLookAtGoal(this, LivingEntity.class, 10.0F)); this.targetSelector.addGoal(1, new SmartHurtByTargetGoal(this)); this.targetSelector.addGoal(2, new ProtectChildrenTarget<>(this, LivingEntity.class, true, input -> !(input instanceof EntityBear))); this.targetSelector.addGoal(3, new HuntMobTarget<>(this, LivingEntity.class, true, 30, false, input -> getEcoLevel(input) < getEcoLevel(this))); this.targetSelector.addGoal(4, new AngrySleeperTarget<>(this, LivingEntity.class, true)); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 5.0D) .add(Attributes.ATTACK_KNOCKBACK, 1D) .add(Attributes.MOVEMENT_SPEED, 0.15D) .add(Attributes.FOLLOW_RANGE, 24D) .add(Attributes.MAX_HEALTH, 30.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 1D) .add(Attributes.ARMOR, 4D); } public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this) && this.getHunger() >= 80) { if (ConfigGamerules.hardcoreBreeding.get()) { List<LivingEntity> list = this.level.getEntitiesOfClass(LivingEntity.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); return list.size() < 3; } return true; } } return false; } @Nullable public EntityBear getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { return create_offspring(new EntityBear(ModEntity.BEAR.get(), this.level)); } public boolean isPushedByFluid() { return false; } public void aiStep() { if (!this.level.isClientSide) { if (this.tickCount % 1000 == 0) { this.addHunger(-2); if (!this.isStarving()) { this.heal(2.0F); } } // Bearserk if (this.getHealth() < this.getMaxHealth() / 2) { this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, 1200, 0, true, true)); this.forceSleep = -1200; } this.setAngry(this.getTarget() != null); if (this.getAnimation() == NO_ANIMATION && this.getTarget() == null && !this.isSleeping()) { if (this.getCommandInt() == 0) { int i = this.random.nextInt(3000); if (i == 0 && !this.isInWater() && this.isNotMoving() && this.canMove() && this.isActive()) { this.getNavigation().stop(); this.setSitting(true); } if ((i == 1 || this.isInWater()) && this.isSitting() && this.getCommandInt() < 2) { this.setSitting(false); } if (i == 2 && this.canMove() && !this.isInWater() && !this.isBaby()) { if (!this.isSitting()) { this.setAnimation(IDLE_STAND); } } if (i > 2980 && !this.isInWater() && !this.isBaby()) { this.setAnimation(IDLE_TALK); } } } } if (this.tickCount % 100 == 0 && this.getTarget() != null && this.getAnimation() == NO_ANIMATION) { this.setAnimation(ANIMATION_ROAR); } if (this.getAnimation() != NO_ANIMATION) { if (this.getAnimation() == ATTACK_BITE && this.getAnimationTick() == 1) { this.playSound(ModSounds.ENTITY_ATTACK_BITE, 1.5F, 0.8F); } if (this.getAnimation() == ATTACK_SWIPE && this.getAnimationTick() == 8) { this.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, 1.5F, 0.8F); } if (this.getAnimation() == ATTACK_POUND && this.getAnimationTick() == 10) { this.getMoveControl().strafe(2F, 0); this.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, 1.5F, 0.8F); } if (this.getAnimation() == ATTACK_MAUL) { if (this.getAnimationTick() == 10) { this.playSound(this.getThreatSound(), this.getSoundVolume(), this.getVoicePitch()); } if (this.getAnimationTick() == 20) { this.playSound(SoundEvents.PLAYER_SMALL_FALL, 1.5F, 0.8F); if (!this.level.isClientSide()) { BlockPos pos = this.blockPosition().below(); BlockState state = this.level.getBlockState(pos); if (!state.addLandingEffects((ServerLevel) this.level, pos, state, this, 40)) ((ServerLevel)this.level).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, state), this.getX(), this.getY(), this.getZ(), 40, 0.0D, 0.0D, 0.0D, 99.3F); } } } if (this.getAnimation() == ANIMATION_ROAR && this.getAnimationTick() == 7) { this.playSound(this.getThreatSound(), this.getSoundVolume(), this.getVoicePitch()); } if (this.getAnimation() == IDLE_TALK && this.getAnimationTick() == 1) { this.playSound(ModSounds.ENTITY_BEAR_AMBIENT, this.getSoundVolume(), this.getVoicePitch()); } if (this.getAnimation() == ANIMATION_EAT && (this.getAnimationTick() == 10 || this.getAnimationTick() == 20 || this.getAnimationTick() == 30)) { this.playSound(SoundEvents.HORSE_EAT, 1.5F, 0.8F); } } super.aiStep(); } @Override protected void reassessTameGoals() { if (this.isTame()) { if (UntamedWilds.DEBUG) { UntamedWilds.LOGGER.info("Updating AI tasks for tamed mob"); } this.goalSelector.addGoal(3, new SmartFollowOwnerGoal(this, 2.3D, 12.0F, 3.0F)); this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this)); this.targetSelector.addGoal(2, new SmartOwnerHurtTargetGoal(this)); } } public double getMountedYOffset() { return getModelScale() + 0.5f * this.getMobSize(); } protected SoundEvent getAmbientSound() { return !this.isBaby() ? super.getAmbientSound() : ModSounds.ENTITY_BEAR_BABY_AMBIENT; } protected SoundEvent getHurtSound(@NotNull DamageSource source) { return !this.isBaby() ? super.getHurtSound(source) : ModSounds.ENTITY_BEAR_BABY_CRY; } protected SoundEvent getDeathSound() { return super.getDeathSound(); } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.POLAR_BEAR_STEP, 0.15F, 1.0F); } public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { Animation anim = chooseAttackAnimation(); this.setAnimation(anim); this.setAnimationTick(0); } return flag; } public boolean hurt(DamageSource damageSource, float amount) { // Retaliate II: Mob will strike back when attacked by any mob performRetaliation(damageSource, this.getHealth(), amount, false); return super.hurt(damageSource, amount); } public boolean isInvulnerableTo(DamageSource source) { return super.isInvulnerableTo(source) || source == DamageSource.SWEET_BERRY_BUSH; } private Animation chooseAttackAnimation() { return switch (this.random.nextInt(4)) { case 0 -> ATTACK_SWIPE; case 1 -> ATTACK_BITE; case 2 -> ATTACK_MAUL; default -> ATTACK_POUND; }; } protected float getStandingEyeHeight(Pose poseIn, EntityDimensions sizeIn) { return sizeIn.height * 0.85F; } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { if (!this.isTame() && this.isBaby() && EntityUtils.hasFullHealth(this) && this.isFood(itemstack)) { this.playSound(SoundEvents.HORSE_EAT, 1.5F, 0.8F); if (this.getRandom().nextInt(3) == 0) { this.tame(player); EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.HEART, 3, 6); } else { EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.SMOKE, 3, 3); } } } return super.mobInteract(player, hand); } public Animation getAnimationEat() { return ANIMATION_EAT; } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, ANIMATION_ROAR, IDLE_STAND, IDLE_TALK, ANIMATION_EAT, ATTACK_MAUL, ATTACK_BITE, ATTACK_SWIPE, ATTACK_POUND}; } // Flags Parameters public boolean isPanda() { return getEntityData(this.getType()).getFlags(this.getVariant(), "isPanda") == 1; } @Override public void updateAttributes() { this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getAttack()); this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getHealth()); this.setHealth(this.getMaxHealth()); this.setShortSnout(getEntityData(this.getType()).getFlags(this.getVariant(), "hasShortSnout") == 1); this.setHump(getEntityData(this.getType()).getFlags(this.getVariant(), "hasHump") == 1); } public boolean hasShortSnout(){ return (this.entityData.get(SHORT_SNOUT)); } private void setShortSnout(boolean short_snout){ this.entityData.set(SHORT_SNOUT, short_snout); } public boolean hasHump(){ return (this.entityData.get(BACK_HUMP)); } private void setHump(boolean hump){ this.entityData.set(BACK_HUMP, hump); } // TODO: Very shitty hardcoded solution for Blind Cave Bears to keep spawning public SpawnGroupData finalizeSpawn(ServerLevelAccessor worldIn, DifficultyInstance difficultyIn, MobSpawnType reason, @Nullable SpawnGroupData spawnDataIn, @Nullable CompoundTag dataTag) { SpawnGroupData data = super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); if (this.getY() < 53) { this.setVariant(1); } return data; } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("hasShortSnout", this.hasShortSnout()); compound.putBoolean("hasHump", this.hasHump()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setShortSnout(compound.getBoolean("hasShortSnout")); this.setHump(compound.getBoolean("hasHump")); } }
15,168
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityHyena.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityHyena.java
package untamedwilds.entity.mammal; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal; import net.minecraft.world.item.ItemStack; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionHand; import net.minecraft.sounds.SoundEvents; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import untamedwilds.UntamedWilds; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.target.*; import untamedwilds.init.ModEntity; import untamedwilds.init.ModSounds; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; public class EntityHyena extends ComplexMobTerrestrial implements INewSkins, ISpecies, IPackEntity, INeedsPostUpdate { public static Animation ATTACK_POUNCE; public static Animation IDLE_TALK; public static Animation ATTACK_BITE; public EntityHyena(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); IDLE_TALK = Animation.create(20); ATTACK_POUNCE = Animation.create(42); ATTACK_BITE = Animation.create(15); this.maxUpStep = 1F; this.turn_speed = 0.1F; } public void registerGoals() { this.goalSelector.addGoal(1, new SmartSwimGoal_Land(this)); this.goalSelector.addGoal(2, new FindItemsGoal(this, 12, true)); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 1.8D, false, 1, false, false)); this.goalSelector.addGoal(3, new SmartAvoidGoal<>(this, LivingEntity.class, 16, 1.2D, 1.6D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(4, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(4, new GotoSleepGoal(this, 1D)); this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25D)); this.goalSelector.addGoal(5, new SmartWanderGoal(this, 1D, true)); this.goalSelector.addGoal(6, new SmartLookAtGoal(this, LivingEntity.class, 10.0F)); this.targetSelector.addGoal(1, new HurtPackByTargetGoal(this).setAlertOthers(EntityHyena.class)); this.targetSelector.addGoal(2, new ProtectChildrenTarget<>(this, LivingEntity.class, true, input -> !(input instanceof EntityHyena))); this.targetSelector.addGoal(3, new HuntPackMobTarget<>(this, LivingEntity.class, true, 30, false, input -> getEcoLevel(input) < getEcoLevel(this))); this.targetSelector.addGoal(4, new AngrySleeperTarget<>(this, LivingEntity.class, true)); } @Override protected void reassessTameGoals() { if (this.isTame()) { if (UntamedWilds.DEBUG) { UntamedWilds.LOGGER.info("Updating AI tasks for tamed mob"); } this.goalSelector.addGoal(3, new SmartFollowOwnerGoal(this, 1.3D, 12.0F, 3.0F)); this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this)); this.targetSelector.addGoal(2, new SmartOwnerHurtTargetGoal(this)); } } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 6.0D) .add(Attributes.ATTACK_KNOCKBACK, 0.4D) .add(Attributes.MOVEMENT_SPEED, 0.2D) .add(Attributes.FOLLOW_RANGE, 24.0D) .add(Attributes.MAX_HEALTH, 20.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0.2); } public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.age == 0) { return this.getHunger() >= 80; } return false; } @Override public void aiStep() { if (!this.level.isClientSide) { if (this.herd == null) { IPackEntity.initPack(this); } else { this.herd.tick(); } if (this.level.getGameTime() % 1000 == 0) { this.addHunger(-10); if (!this.isStarving()) { this.heal(1.0F); } } // Random idle animations if (this.getAnimation() == NO_ANIMATION && this.getTarget() == null && !this.isSleeping()) { if (this.getCommandInt() == 0) { int i = this.random.nextInt(3000); if (i == 0 && !this.isInWater() && this.isNotMoving() && this.canMove() && this.isActive()) { this.getNavigation().stop(); this.setSitting(true); } if ((i == 1 || this.isInWater()) && this.isSitting() && this.getCommandInt() < 2) { this.setSitting(false); } if (i > 2980 && !this.isInWater() && !this.isBaby()) { this.setAnimation(IDLE_TALK); } } } this.setAngry(this.getTarget() != null); if (this.getAnimation() == ATTACK_POUNCE && this.getAnimationTick() == 10) { this.getMoveControl().strafe(2F, 0); this.getJumpControl().jump(); } if (this.getAnimation() == IDLE_TALK && this.getAnimationTick() == 1 && this.getAmbientSound() != null) { this.playSound(this.getAmbientSound(), this.getSoundVolume(), this.getVoicePitch()); } if (this.getTarget() != null && this.tickCount % 120 == 0) { this.playSound(this.getThreatSound(), this.getSoundVolume(), this.getVoicePitch()); } } if (this.getAnimation() != NO_ANIMATION) { if (this.getAnimation() == ATTACK_BITE && this.getAnimationTick() == 6) { this.playSound(ModSounds.ENTITY_ATTACK_BITE, 1.5F, 0.8F); } } super.aiStep(); } public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { Animation anim = chooseAttackAnimation(); this.setAnimation(anim); } return flag; } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.WOLF_STEP, 0.15F, 1.0F); } private Animation chooseAttackAnimation() { return switch (this.random.nextInt(4)) { case 0 -> ATTACK_POUNCE; case 1 -> ATTACK_POUNCE; default -> ATTACK_BITE; }; } @Nullable public EntityHyena getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { return create_offspring(new EntityHyena(ModEntity.HYENA.get(), this.level)); } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { if (!this.isTame() && this.isBaby() && EntityUtils.hasFullHealth(this) && this.isFood(itemstack)) { this.playSound(SoundEvents.HORSE_EAT, 1.5F, 0.8F); if (this.getRandom().nextInt(3) == 0) { this.tame(player); EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.HEART, 3, 6); } else { EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.SMOKE, 3, 3); } } } return super.mobInteract(player, hand); } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, ATTACK_POUNCE, ATTACK_BITE, IDLE_TALK}; } public Animation getAnimationEat() { return NO_ANIMATION; } @Override public void updateAttributes() { this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getAttack()); this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getHealth()); this.setHealth(this.getMaxHealth()); } }
8,650
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityBison.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityBison.java
package untamedwilds.entity.mammal; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal; import net.minecraft.world.entity.ai.util.DefaultRandomPos; import net.minecraft.world.entity.monster.hoglin.HoglinBase; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import untamedwilds.UntamedWilds; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.target.ProtectChildrenTarget; import untamedwilds.entity.ai.target.SmartOwnerHurtTargetGoal; import untamedwilds.entity.ai.unique.BisonTerritorialityFight; import untamedwilds.init.ModEntity; import untamedwilds.init.ModSounds; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.EnumSet; public class EntityBison extends ComplexMobTerrestrial implements INewSkins, ISpecies, IPackEntity { private static final EntityDataAccessor<Boolean> CHARGING = SynchedEntityData.defineId(EntityBison.class, EntityDataSerializers.BOOLEAN); public static Animation ATTACK_THREATEN; public static Animation ATTACK_GORE; public EntityBison(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); ATTACK_THREATEN = Animation.create(50); ATTACK_GORE = Animation.create(14); this.maxUpStep = 1F; this.turn_speed = 0.2F; } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(CHARGING, false); } public void registerGoals() { this.goalSelector.addGoal(1, new SmartSwimGoal_Land(this)); this.goalSelector.addGoal(2, new RodeoGoal(this, 1.8F)); this.goalSelector.addGoal(2, new MeleeAttackCharger(this, 1.4F, 3)); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 1.6D, false)); this.goalSelector.addGoal(3, new SmartMateGoal(this, 0.8D)); this.goalSelector.addGoal(3, new GrazeGoal(this, 10)); this.goalSelector.addGoal(4, new GotoSleepGoal(this, 1D)); this.goalSelector.addGoal(5, new BisonTerritorialityFight(this, 1.4F)); this.goalSelector.addGoal(5, new SmartWanderGoal(this, 1D, 120, 0, true)); this.goalSelector.addGoal(6, new SmartLookAtGoal(this, LivingEntity.class, 10.0F)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); this.targetSelector.addGoal(2, new ProtectChildrenTarget<>(this, LivingEntity.class, true, input -> !(input instanceof EntityBison) && getEcoLevel(input) > getEcoLevel(this))); } @Override protected void reassessTameGoals() { if (this.isTame()) { if (UntamedWilds.DEBUG) { UntamedWilds.LOGGER.info("Updating AI tasks for tamed mob"); } this.goalSelector.addGoal(3, new SmartFollowOwnerGoal(this, 1.3D, 12.0F, 3.0F)); this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this)); this.targetSelector.addGoal(2, new SmartOwnerHurtTargetGoal(this)); } } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 7.0D) .add(Attributes.ATTACK_KNOCKBACK, 1.5D) .add(Attributes.MOVEMENT_SPEED, 0.2D) .add(Attributes.FOLLOW_RANGE, 12.0D) .add(Attributes.MAX_HEALTH, 35.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 1D) .add(Attributes.ARMOR, 2D); } public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.age == 0) { return this.getHunger() >= 80; } return false; } @Override public void aiStep() { if (!this.level.isClientSide) { if (this.herd == null) { IPackEntity.initPack(this); } else { this.herd.tick(); } if (this.level.getGameTime() % 1000 == 0) { this.addHunger(-10); if (!this.isStarving()) { this.heal(1.0F); } } int i = this.random.nextInt(3000); if (i == 13 && !this.isInWater() && this.getTarget() == null && this.isNotMoving() && this.canMove() && this.getAnimation() == NO_ANIMATION) { this.setSitting(true); } if (i == 14 && this.isSitting()) { this.setSitting(false); } this.setAngry(this.getTarget() != null); } else { if (this.getAnimation() == ATTACK_THREATEN) { this.setSprinting(this.getAnimationTick() % 18 < 6); } } super.aiStep(); } public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { Animation anim = chooseAttackAnimation(); this.setAnimation(anim); if (!this.isCharging()) { this.playSound(SoundEvents.ZOGLIN_ATTACK, 1.0F, this.getVoicePitch()); HoglinBase.hurtAndThrowTarget(this, (LivingEntity)entityIn); } } return flag; } public boolean hurt(DamageSource damageSource, float amount) { // Retaliate I: Mob will strike back when attacked by its current target performRetaliation(damageSource, this.getHealth(), amount, true); return super.hurt(damageSource, amount); } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.RAVAGER_STEP, 0.15F, 1.0F); } private Animation chooseAttackAnimation() { return ATTACK_GORE; } @Nullable public EntityBison getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { return create_offspring(new EntityBison(ModEntity.BISON.get(), this.level)); } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { if (!this.isTame() && this.isBaby() && EntityUtils.hasFullHealth(this) && this.isFood(itemstack)) { this.playSound(SoundEvents.HORSE_EAT, 1.5F, 0.8F); if (this.getRandom().nextInt(3) == 0) { this.tame(player); EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.HEART, 3, 6); } else { EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.SMOKE, 3, 3); } } if (!this.isTame() && !this.isBaby() && itemstack.isEmpty()) { this.setSitting(false); this.setSleeping(false); if (!this.level.isClientSide) { player.setYRot(this.getYRot()); player.setXRot(this.getXRot()); player.startRiding(this); } } } return super.mobInteract(player, hand); } public boolean isCharging() { return entityData.get(CHARGING); } public void setCharging(boolean bool) { entityData.set(CHARGING, bool); } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, ATTACK_THREATEN, ATTACK_GORE}; } public Animation getAnimationEat() { return NO_ANIMATION; } public static class RodeoGoal extends Goal { private final EntityBison bison; private final double speedModifier; private double posX; private double posY; private double posZ; public RodeoGoal(EntityBison p_25890_, double p_25891_) { this.bison = p_25890_; this.speedModifier = p_25891_; this.setFlags(EnumSet.of(Goal.Flag.MOVE)); } public boolean canUse() { if (!this.bison.isTame() && this.bison.isVehicle()) { Vec3 vec3 = DefaultRandomPos.getPos(this.bison, 5, 4); if (vec3 == null) { return false; } else { this.posX = vec3.x; this.posY = vec3.y; this.posZ = vec3.z; return true; } } else { return false; } } public void start() { this.bison.getNavigation().moveTo(this.posX, this.posY, this.posZ, this.speedModifier); } public boolean canContinueToUse() { return !this.bison.isTame() && !this.bison.getNavigation().isDone() && this.bison.isVehicle(); } public void tick() { if (this.bison.getRandom().nextInt(this.adjustedTickDelay(50)) < 3) { this.bison.setAnimation(ATTACK_GORE); this.bison.playSound(ModSounds.ENTITY_BISON_AMBIENT, this.bison.getSoundVolume(), this.bison.getVoicePitch()); } if (!this.bison.isTame() && this.bison.getRandom().nextInt(this.adjustedTickDelay(50)) == 0) { Entity entity = this.bison.getPassengers().get(0); if (entity == null) { return; } this.bison.ejectPassengers(); this.bison.setTarget((LivingEntity) entity); this.bison.level.broadcastEntityEvent(this.bison, (byte)6); } } } }
10,766
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityRhino.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityRhino.java
package untamedwilds.entity.mammal; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal; import net.minecraft.world.entity.monster.hoglin.HoglinBase; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import untamedwilds.UntamedWilds; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.target.ProtectChildrenTarget; import untamedwilds.entity.ai.target.SmartOwnerHurtTargetGoal; import untamedwilds.init.ModEntity; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; public class EntityRhino extends ComplexMobTerrestrial implements INewSkins, ISpecies, INeedsPostUpdate { private static final EntityDataAccessor<Boolean> CHARGING = SynchedEntityData.defineId(EntityRhino.class, EntityDataSerializers.BOOLEAN); public static Animation ATTACK_THREATEN; public static Animation ATTACK_GORE; public EntityRhino(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); ATTACK_THREATEN = Animation.create(50); ATTACK_GORE = Animation.create(14); this.maxUpStep = 1F; this.turn_speed = 0.2F; } protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(CHARGING, false); } public void registerGoals() { this.goalSelector.addGoal(2, new MeleeAttackCharger(this, 1.4F, 3)); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 1.6D, false)); this.goalSelector.addGoal(3, new SmartMateGoal(this, 0.8D)); this.goalSelector.addGoal(3, new GrazeGoal(this, 10)); this.goalSelector.addGoal(4, new GotoSleepGoal(this, 1D)); this.goalSelector.addGoal(5, new SmartWanderGoal(this, 1D, 120, 0, true)); this.goalSelector.addGoal(6, new SmartLookAtGoal(this, LivingEntity.class, 10.0F)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); this.targetSelector.addGoal(2, new ProtectChildrenTarget<>(this, LivingEntity.class, true, input -> !(input instanceof EntityRhino) && getEcoLevel(input) > getEcoLevel(this))); } @Override protected void reassessTameGoals() { if (this.isTame()) { if (UntamedWilds.DEBUG) { UntamedWilds.LOGGER.info("Updating AI tasks for tamed mob"); } this.goalSelector.addGoal(3, new SmartFollowOwnerGoal(this, 1.3D, 12.0F, 3.0F)); this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this)); this.targetSelector.addGoal(2, new SmartOwnerHurtTargetGoal(this)); } } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 8.0D) .add(Attributes.ATTACK_KNOCKBACK, 1.6D) .add(Attributes.MOVEMENT_SPEED, 0.2D) .add(Attributes.FOLLOW_RANGE, 24.0D) .add(Attributes.MAX_HEALTH, 60.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 1D) .add(Attributes.ARMOR, 6D); } public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.age == 0) { return this.getHunger() >= 80; } return false; } @Override public void aiStep() { if (!this.level.isClientSide) { if (this.level.getGameTime() % 1000 == 0) { this.addHunger(-10); if (!this.isStarving()) { this.heal(1.0F); } } int i = this.random.nextInt(3000); if (i == 13 && !this.isInWater() && this.getTarget() == null && this.isNotMoving() && this.canMove() && this.getAnimation() == NO_ANIMATION) { this.setSitting(true); } if (i == 14 && this.isSitting()) { this.setSitting(false); } this.setAngry(this.getTarget() != null); } else { if (this.getAnimation() == ATTACK_THREATEN) { this.setSprinting(this.getAnimationTick() % 18 < 6); } } super.aiStep(); } public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { Animation anim = chooseAttackAnimation(); this.setAnimation(anim); if (!this.isCharging()) { this.playSound(SoundEvents.ZOGLIN_ATTACK, 1.0F, this.getVoicePitch()); HoglinBase.hurtAndThrowTarget(this, (LivingEntity)entityIn); } } return flag; } public boolean hurt(DamageSource damageSource, float amount) { // Retaliate II: Mob will strike back when attacked by any target performRetaliation(damageSource, this.getHealth(), amount, false); return super.hurt(damageSource, amount); } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.RAVAGER_STEP, 0.15F, 1.0F); } private Animation chooseAttackAnimation() { return ATTACK_GORE; } @Nullable public EntityRhino getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { return create_offspring(new EntityRhino(ModEntity.RHINO.get(), this.level)); } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { if (!this.isTame() && this.isBaby() && EntityUtils.hasFullHealth(this) && this.isFood(itemstack)) { this.playSound(SoundEvents.HORSE_EAT, 1.5F, 0.8F); if (this.getRandom().nextInt(3) == 0) { this.tame(player); EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.HEART, 3, 6); } else { EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.SMOKE, 3, 3); } } } return super.mobInteract(player, hand); } public boolean isCharging() { return entityData.get(CHARGING); } public void setCharging(boolean bool) { entityData.set(CHARGING, bool); } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, ATTACK_THREATEN, ATTACK_GORE}; } public Animation getAnimationEat() { return NO_ANIMATION; } @Override public void updateAttributes() { this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getAttack()); this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getHealth()); this.setHealth(this.getMaxHealth()); } }
8,116
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityBigCat.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mammal/EntityBigCat.java
package untamedwilds.entity.mammal; import com.github.alexthe666.citadel.animation.Animation; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.NotNull; import untamedwilds.UntamedWilds; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.*; import untamedwilds.entity.ai.*; import untamedwilds.entity.ai.target.*; import untamedwilds.init.ModEntity; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; // TODO: Have Lions use the MeleeAttackCircleHerd goal public class EntityBigCat extends ComplexMobTerrestrial implements ISpecies, INewSkins, INeedsPostUpdate, IPackEntity { private static final EntityDataAccessor<Boolean> DIMORPHISM = SynchedEntityData.defineId(EntityBigCat.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor<Boolean> FLUFFY_TAIL = SynchedEntityData.defineId(EntityBigCat.class, EntityDataSerializers.BOOLEAN); public static Animation ATTACK_MAUL; public static Animation ATTACK_POUNCE; public static Animation ANIMATION_ROAR; public static Animation ANIMATION_EAT; public static Animation IDLE_TALK; public static Animation IDLE_STRETCH; public int aggroProgress; public EntityBigCat(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.entityData.define(DIMORPHISM, false); this.entityData.define(FLUFFY_TAIL, false); ATTACK_POUNCE = Animation.create(42); ATTACK_MAUL = Animation.create(22); IDLE_TALK = Animation.create(20); IDLE_STRETCH = Animation.create(110); this.maxUpStep = 1; this.turn_speed = 0.1F; } public void registerGoals() { this.goalSelector.addGoal(1, new SmartSwimGoal_Land(this)); this.goalSelector.addGoal(2, new FindItemsGoal(this, 12, true)); this.goalSelector.addGoal(2, new SmartMeleeAttackGoal(this, 2.3D, false, 1, false, true)); this.goalSelector.addGoal(3, new SmartAvoidGoal<>(this, LivingEntity.class, 16, 1.2D, 1.6D, input -> getEcoLevel(input) > getEcoLevel(this))); this.goalSelector.addGoal(4, new SmartMateGoal(this, 1D)); this.goalSelector.addGoal(4, new GotoSleepGoal(this, 1D)); this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25D)); this.goalSelector.addGoal(5, new SmartWanderGoal(this, 1D, true)); this.goalSelector.addGoal(6, new SmartLookAtGoal(this, LivingEntity.class, 10.0F)); this.targetSelector.addGoal(1, new SmartHurtByTargetGoal(this)); this.targetSelector.addGoal(2, new AngrySleeperTarget<>(this, LivingEntity.class, true)); this.targetSelector.addGoal(3, new ProtectChildrenTarget<>(this, LivingEntity.class, true, input -> !(input instanceof EntityBigCat))); this.targetSelector.addGoal(4, new HuntMobTarget<>(this, LivingEntity.class, true, 30, false, input -> getEcoLevel(input) < getEcoLevel(this))); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 8.0D) .add(Attributes.ATTACK_KNOCKBACK, 0.8D) .add(Attributes.MOVEMENT_SPEED, 0.16D) .add(Attributes.FOLLOW_RANGE, 32D) .add(Attributes.MAX_HEALTH, 40.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 0.8D) .add(Attributes.ARMOR, 0D); } /* Breeding conditions for the Snow Leopard are: * Cold Biome (T between -1.0 and 0.4) * No other entities nearby */ public boolean wantsToBreed() { if (super.wantsToBreed()) { if (!this.isSleeping() && this.getAge() == 0 && EntityUtils.hasFullHealth(this) && this.getHunger() >= 80) { if (ConfigGamerules.hardcoreBreeding.get()) { List<LivingEntity> list = this.level.getEntitiesOfClass(LivingEntity.class, this.getBoundingBox().inflate(6.0D, 4.0D, 6.0D)); return list.size() < 3; } return true; } } return false; } @Nullable public EntityBigCat getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) { return create_offspring(new EntityBigCat(ModEntity.BIG_CAT.get(), this.level)); } public boolean isPushedByFluid() { return false; } protected int calculateFallDamage(float distance, float damageMultiplier) { return Mth.ceil((distance * 0.5F - 3.0F) * damageMultiplier); } public void aiStep() { if (!this.level.isClientSide) { if (this.herd == null && EntityUtils.getPackSize(this.getType(), this.getVariant()) > 1) { IPackEntity.initPack(this); } else if (EntityUtils.getPackSize(this.getType(), this.getVariant()) > 1) { this.herd.tick(); } if (this.level.getGameTime() % 1000 == 0) { this.addHunger(-3); if (!this.isStarving()) { this.heal(2.0F); } } // Random idle animations if (this.getAnimation() == NO_ANIMATION && this.getTarget() == null && !this.isSleeping()) { if (this.getCommandInt() == 0) { int i = this.random.nextInt(3000); if (i == 0 && !this.isInWater() && this.isNotMoving() && this.canMove() && this.isActive()) { this.getNavigation().stop(); this.setSitting(true); } if ((i == 1 || this.isInWater()) && this.isSitting() && this.getCommandInt() < 2) { this.setSitting(false); } if (i == 2 && this.canMove() && !this.isInWater() && !this.isBaby()) { this.getNavigation().stop(); this.setAnimation(IDLE_STRETCH); } if (i > 2980 && !this.isInWater() && !this.isBaby()) { this.setAnimation(IDLE_TALK); } } } if (this.tickCount % 80 == 2 && this.getTarget() != null && this.getAnimation() == NO_ANIMATION) { this.setAnimation(ANIMATION_ROAR); } if (this.getAnimation() == ATTACK_POUNCE && this.getAnimationTick() == 10) { this.getMoveControl().strafe(2F, 0); this.getJumpControl().jump(); } this.setAngry(this.getTarget() != null); } if (this.getAnimation() == ANIMATION_EAT && (this.getAnimationTick() == 10 || this.getAnimationTick() == 20 || this.getAnimationTick() == 30)) { this.playSound(SoundEvents.HORSE_EAT,1.5F, 0.8F); } if (this.getAnimation() == ATTACK_MAUL && this.getAnimationTick() == 10) { this.playSound(SoundEvents.PLAYER_ATTACK_SWEEP,1.5F, 0.8F); } if (this.getAnimation() == IDLE_TALK && this.getAnimationTick() == 1 && this.getAmbientSound() != null) { this.playSound(this.getAmbientSound(), this.getSoundVolume(), this.getVoicePitch()); } if (this.level.isClientSide && this.isAngry() && this.aggroProgress < 40) { this.aggroProgress++; } else if (this.level.isClientSide && !this.isAngry() && this.aggroProgress > 0) { this.aggroProgress--; } super.aiStep(); } protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.WOLF_STEP, 0.15F, 1.0F); } @Override protected void reassessTameGoals() { if (this.isTame()) { if (UntamedWilds.DEBUG) { UntamedWilds.LOGGER.info("Updating AI tasks for tamed mob"); } this.goalSelector.addGoal(3, new SmartFollowOwnerGoal(this, 2.3D, 12.0F, 3.0F)); this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this)); this.targetSelector.addGoal(2, new SmartOwnerHurtTargetGoal(this)); } } protected SoundEvent getAmbientSound() { return this.isBaby() ? SoundEvents.OCELOT_AMBIENT : super.getAmbientSound(); } protected SoundEvent getHurtSound(@NotNull DamageSource source) { return this.isBaby() ? SoundEvents.OCELOT_HURT : super.getHurtSound(source); } protected SoundEvent getDeathSound() { return this.isBaby() ? SoundEvents.OCELOT_DEATH : super.getDeathSound(); } public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (hand == InteractionHand.MAIN_HAND && !this.level.isClientSide()) { if (!this.isTame() && this.isBaby() && EntityUtils.hasFullHealth(this) && this.isFood(itemstack)) { this.playSound(SoundEvents.HORSE_EAT, 1.5F, 0.8F); if (this.getRandom().nextInt(3) == 0) { this.tame(player); EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.HEART, 3, 6); } else { EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.SMOKE, 3, 3); } } } return super.mobInteract(player, hand); } public boolean doHurtTarget(Entity entityIn) { boolean flag = super.doHurtTarget(entityIn); if (flag && this.getAnimation() == NO_ANIMATION && !this.isBaby()) { Animation anim = chooseAttackAnimation(entityIn); this.setAnimation(anim); this.setAnimationTick(0); } return flag; } public boolean hurt(DamageSource damageSource, float amount) { // Retaliate I: Mob will strike back when attacked by its current target float f = this.getHealth(); if (!this.level.isClientSide && !this.isNoAi() && this.getTarget() == damageSource.getEntity() && amount < f && (damageSource.getEntity() != null || damageSource.getDirectEntity() != null) && damageSource.getEntity() instanceof LivingEntity && (damageSource.getEntity() instanceof TamableAnimal tamable && tamable.getOwner() != null)) { if (this.hasLineOfSight(damageSource.getEntity()) && !damageSource.getEntity().isInvulnerable() && this.getAnimation() == NO_ANIMATION) { this.doHurtTarget(damageSource.getEntity()); } } return super.hurt(damageSource, amount); } private Animation chooseAttackAnimation(Entity target) { if (target.getBbHeight() < this.getBbHeight()) { return ATTACK_MAUL; } return ATTACK_POUNCE; } //public Animation getAnimationEat() { return ANIMATION_EAT; } @Override public Animation[] getAnimations() { return new Animation[]{NO_ANIMATION, ATTACK_POUNCE, ATTACK_MAUL, IDLE_TALK, IDLE_STRETCH}; } protected float getStandingEyeHeight(Pose poseIn, EntityDimensions sizeIn) { return sizeIn.height * 0.9F; } @Override public void updateAttributes() { this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getAttack()); this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(getEntityData(this.getType()).getSpeciesData().get(this.getVariant()).getHealth()); this.setHealth(this.getMaxHealth()); this.setDimorphism(getEntityData(this.getType()).getFlags(this.getVariant(), "dimorphism") == 1); this.setFluffyTail(getEntityData(this.getType()).getFlags(this.getVariant(), "fluffyTail") == 1); } public boolean hasDimorphism(){ return (this.entityData.get(DIMORPHISM)); } private void setDimorphism(boolean dimorphism){ this.entityData.set(DIMORPHISM, dimorphism); } public boolean hasFluffyTail(){ return (this.entityData.get(FLUFFY_TAIL)); } private void setFluffyTail(boolean fluffy_tail){ this.entityData.set(FLUFFY_TAIL, fluffy_tail); } public void addAdditionalSaveData(CompoundTag compound){ super.addAdditionalSaveData(compound); compound.putBoolean("hasDimorphism", this.hasDimorphism()); compound.putBoolean("fluffy", this.hasFluffyTail()); } public void readAdditionalSaveData(CompoundTag compound){ super.readAdditionalSaveData(compound); this.setDimorphism(compound.getBoolean("hasDimorphism")); this.setFluffyTail(compound.getBoolean("fluffy")); } public ResourceLocation getTexture() { ResourceLocation texture_path = EntityUtils.getSkinFromEntity(this); if (this.hasDimorphism()) { String trimmed_path = texture_path.getPath().substring(0, texture_path.getPath().lastIndexOf('.')); return new ResourceLocation(UntamedWilds.MOD_ID, trimmed_path + "_" + this.getGenderString() + ".png"); } return texture_path; } }
14,073
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
Spit.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/projectile/Spit.java
package untamedwilds.entity.projectile; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.animal.horse.Llama; import net.minecraft.world.entity.projectile.LlamaSpit; import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.ProjectileUtil; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; public class Spit extends Projectile { public Spit(EntityType<? extends LlamaSpit> p_37224_, Level p_37225_) { super(p_37224_, p_37225_); } public Spit(Level p_37235_, Llama p_37236_) { this(EntityType.LLAMA_SPIT, p_37235_); this.setOwner(p_37236_); this.setPos(p_37236_.getX() - (double)(p_37236_.getBbWidth() + 1.0F) * 0.5D * (double) Mth.sin(p_37236_.yBodyRot * ((float)Math.PI / 180F)), p_37236_.getEyeY() - (double)0.1F, p_37236_.getZ() + (double)(p_37236_.getBbWidth() + 1.0F) * 0.5D * (double)Mth.cos(p_37236_.yBodyRot * ((float)Math.PI / 180F))); } public void tick() { super.tick(); Vec3 vec3 = this.getDeltaMovement(); HitResult hitresult = ProjectileUtil.getHitResult(this, this::canHitEntity); if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) this.onHit(hitresult); double d0 = this.getX() + vec3.x; double d1 = this.getY() + vec3.y; double d2 = this.getZ() + vec3.z; this.updateRotation(); float f = 0.99F; float f1 = 0.06F; if (this.level.getBlockStates(this.getBoundingBox()).noneMatch(BlockBehaviour.BlockStateBase::isAir)) { this.discard(); } else if (this.isInWaterOrBubble()) { this.discard(); } else { this.setDeltaMovement(vec3.scale(0.99F)); if (!this.isNoGravity()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.06F, 0.0D)); } this.setPos(d0, d1, d2); } } protected void onHitEntity(EntityHitResult p_37241_) { super.onHitEntity(p_37241_); Entity entity = this.getOwner(); if (entity instanceof LivingEntity) { p_37241_.getEntity().hurt(DamageSource.indirectMobAttack(this, (LivingEntity)entity).setProjectile(), 1.0F); } } protected void onHitBlock(BlockHitResult p_37239_) { super.onHitBlock(p_37239_); if (!this.level.isClientSide) { this.discard(); } } protected void defineSynchedData() { } public void recreateFromPacket(ClientboundAddEntityPacket p_150162_) { super.recreateFromPacket(p_150162_); double d0 = p_150162_.getXa(); double d1 = p_150162_.getYa(); double d2 = p_150162_.getZa(); for(int i = 0; i < 7; ++i) { double d3 = 0.4D + 0.1D * (double)i; this.level.addParticle(ParticleTypes.SPIT, this.getX(), this.getY(), this.getZ(), d0 * d3, d1, d2 * d3); } this.setDeltaMovement(d0, d1, d2); } }
3,592
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
EntityGiantClam.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/mollusk/EntityGiantClam.java
package untamedwilds.entity.mollusk; import net.minecraft.core.Direction; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ShovelItem; import net.minecraft.world.level.Level; import net.minecraft.world.level.pathfinder.BlockPathTypes; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.INewSkins; import untamedwilds.entity.ISpecies; import untamedwilds.util.EntityUtils; import javax.annotation.Nullable; import java.util.List; public class EntityGiantClam extends ComplexMob implements ISpecies, INewSkins { private static final EntityDataAccessor<Boolean> CLAM_OPEN = SynchedEntityData.defineId(EntityGiantClam.class, EntityDataSerializers.BOOLEAN); public int closeProgress; public EntityGiantClam(EntityType<? extends ComplexMob> type, Level worldIn) { super(type, worldIn); this.entityData.define(CLAM_OPEN, false); this.setPathfindingMalus(BlockPathTypes.WATER, 0.0F); } public static AttributeSupplier.Builder registerAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 0D) .add(Attributes.MOVEMENT_SPEED, 0D) .add(Attributes.FOLLOW_RANGE, 1D) .add(Attributes.MAX_HEALTH, 20.0D) .add(Attributes.KNOCKBACK_RESISTANCE, 1D) .add(Attributes.ARMOR, 12D); } protected void defineSynchedData() { super.defineSynchedData(); //this.entityData.define(CLAM_OPEN, true); //this.entityCollisionReduction = 1F; } @Override public void baseTick() { int i = this.getAirSupply(); super.baseTick(); if (this.isAlive() && !this.isInWaterOrBubble()) { --i; this.setAirSupply(i); if (this.getAirSupply() == -20) { this.setAirSupply(0); this.hurt(DamageSource.DRY_OUT, 2.0F); } } else { this.setAirSupply(300); } } public void aiStep() { super.aiStep(); // The following locks the X and Z position to zero, preventing the entity from being pushed this.setDeltaMovement(0, this.getDeltaMovement().get(Direction.Axis.Y), 0); if (!this.level.isClientSide) { if (this.isInWater() && this.isOpen() && this.getRandom().nextFloat() > 0.99) { ((ServerLevel) this.level).sendParticles(ParticleTypes.BUBBLE_COLUMN_UP, this.getPosition(0).x, this.getPosition(0).y + 0.2, this.getPosition(0).z, 1, random.nextFloat() * 0.2, random.nextFloat() * 0.2, random.nextFloat() * 0.2, 0); } if (this.tickCount % 1000 == 0) { if (this.wantsToBreed()) { this.breed(); } } this.setOpen(this.level.isDay()); } if (this.level.isClientSide) { if (!this.isOpen() && this.closeProgress < 200) { this.closeProgress++; } else if (this.isOpen() && this.closeProgress > 0) { this.closeProgress--; } } } /* Breeding conditions for the Giant Clam are: * A nearby Giant Clam of the same species, being hermaphrodites, they do not take Gender into account */ public boolean wantsToBreed() { if (ConfigGamerules.naturalBreeding.get() && this.getAge() == 0 && EntityUtils.hasFullHealth(this)) { List<EntityGiantClam> list = this.level.getEntitiesOfClass(EntityGiantClam.class, this.getBoundingBox().inflate(12.0D, 6.0D, 12.0D)); list.removeIf(input -> input == this || input.getAge() != 0 || input.getVariant() != this.getVariant()); if (list.size() >= 1) { this.setAge(this.getPregnancyTime()); list.get(0).setAge(this.getPregnancyTime()); return true; } } return false; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageableEntity) { EntityUtils.dropEggs(this, "egg_giant_clam", this.getOffspring()); return null; } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(InteractionHand.MAIN_HAND); if (itemstack.getItem() instanceof ShovelItem && this.isAlive() && hand == InteractionHand.MAIN_HAND) { if (this.random.nextInt(4) == 0) { this.level.playSound(null, this.blockPosition(), SoundEvents.SHIELD_BLOCK, SoundSource.BLOCKS, 1.0F, 0.8F); EntityUtils.turnEntityIntoItem(this, "spawn_giant_clam"); return InteractionResult.sidedSuccess(this.level.isClientSide); } else { this.level.playSound(null, this.blockPosition(), SoundEvents.SHULKER_HURT_CLOSED, SoundSource.BLOCKS, 1.0F, 0.8F); EntityUtils.spawnParticlesOnEntity(this.level, this, ParticleTypes.SMOKE, 3, 1); } } return super.mobInteract(player, hand); } public boolean canBeTargeted() { return false; } private boolean isOpen(){ return (this.entityData.get(CLAM_OPEN)); } private void setOpen(boolean open){ this.entityData.set(CLAM_OPEN, open); } public void addAdditionalSaveData(CompoundTag compound){ // Write NBT Tags super.addAdditionalSaveData(compound); compound.putBoolean("isOpen", this.isOpen()); } public void readAdditionalSaveData(CompoundTag compound){ // Read NBT Tags super.readAdditionalSaveData(compound); this.setOpen(compound.getBoolean("isOpen")); } }
6,597
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
FishReturnToSchoolGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/FishReturnToSchoolGoal.java
package untamedwilds.entity.ai; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.ai.behavior.BehaviorUtils; import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal; import net.minecraft.world.phys.Vec3; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.ComplexMobAquatic; import untamedwilds.entity.IPackEntity; public class FishReturnToSchoolGoal extends RandomSwimmingGoal { private final ComplexMob taskOwner; private final int maxDist; private boolean hasReachedLeader; public FishReturnToSchoolGoal(ComplexMobAquatic entityIn) { this(entityIn, 2D, 10, 5); } public FishReturnToSchoolGoal(ComplexMobAquatic entityIn, double speedIn, int chance, int maxDist) { super(entityIn, speedIn, chance); this.maxDist = maxDist; this.taskOwner = entityIn; } @Override public boolean canUse() { if (!(this.mob instanceof IPackEntity) || this.taskOwner.herd == null || this.taskOwner.herd.getLeader() == this.taskOwner || this.taskOwner.distanceTo(this.taskOwner.herd.getLeader()) < this.maxDist) { return false; } return super.canUse(); } public boolean canContinueToUse() { return super.canContinueToUse() && !this.hasReachedLeader; } public void tick() { super.tick(); if (this.taskOwner.distanceTo(this.taskOwner.herd.getLeader()) < this.maxDist) { this.hasReachedLeader = true; this.taskOwner.getNavigation().stop(); BlockPos dest = this.taskOwner.herd.getLeader().getNavigation().getTargetPos(); // TODO: Evaluate if this even triggers? if (dest != null) this.taskOwner.getNavigation().moveTo(dest.getX(), dest.getY(), dest.getZ(), this.speedModifier / 2); } } @Override protected Vec3 getPosition() { Vec3 vec3d = BehaviorUtils.getRandomSwimmablePos(this.taskOwner.herd.getLeader(), 2, 1); return vec3d == null ? BehaviorUtils.getRandomSwimmablePos(this.taskOwner.herd.getLeader(), 2, 1) : vec3d; } }
2,110
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
FishWanderAsSchoolGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/FishWanderAsSchoolGoal.java
package untamedwilds.entity.ai; import net.minecraft.world.entity.ai.behavior.BehaviorUtils; import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal; import net.minecraft.world.entity.ai.util.DefaultRandomPos; import net.minecraft.world.phys.Vec3; import untamedwilds.UntamedWilds; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.ComplexMobAquatic; import untamedwilds.entity.IPackEntity; public class FishWanderAsSchoolGoal extends RandomSwimmingGoal { private final ComplexMob taskOwner; private final int maxDist; public FishWanderAsSchoolGoal(ComplexMobAquatic entityIn) { this(entityIn, 1.0D, 20, 5); } public FishWanderAsSchoolGoal(ComplexMobAquatic entityIn, double speedIn, int chance, int maxDist) { super(entityIn, speedIn, chance); this.maxDist = maxDist; this.taskOwner = entityIn; } @Override public boolean canUse() { if (!(this.mob instanceof IPackEntity)) { return false; } if (this.taskOwner.herd == null || this.taskOwner.herd.getLeader() != this.taskOwner) { return false; } return super.canUse(); } @Override protected Vec3 getPosition() { return BehaviorUtils.getRandomSwimmablePos(this.mob, 20, 7); } @Override public void start() { this.mob.getNavigation().moveTo(this.wantedX, this.wantedY, this.wantedZ, this.speedModifier); for (ComplexMob herd_member : this.taskOwner.herd.creatureList) { //UntamedWilds.LOGGER.info(this.taskOwner.distanceTo(herd_member)); if (this.taskOwner.distanceTo(herd_member) < this.maxDist) { double posX = this.wantedX + (herd_member.getX() - this.taskOwner.getX()); double posY = this.wantedY + (herd_member.getY() - this.taskOwner.getY()); double posZ = this.wantedZ + (herd_member.getZ() - this.taskOwner.getZ()); herd_member.getNavigation().moveTo(posX, posY, posZ, this.speedModifier); } } } }
2,071
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
FishBreachGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/FishBreachGoal.java
package untamedwilds.entity.ai; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.FluidTags; import net.minecraft.util.Mth; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.Vec3; import untamedwilds.entity.ComplexMobAquatic; public class FishBreachGoal extends Goal { private static final int[] JUMP_DISTANCES = new int[]{0, 1, 3, 4}; // Vanilla implementation {0, 1, 4, 5, 6, 7} private final ComplexMobAquatic taskOwner; private final int chance; private boolean inWater; private final boolean safeJumping; public FishBreachGoal(ComplexMobAquatic entityIn, int chance) { this(entityIn, chance, true); } public FishBreachGoal(ComplexMobAquatic entityIn, int chance, boolean safeJumping) { this.taskOwner = entityIn; this.chance = chance; this.safeJumping = safeJumping; } public boolean canUse() { if (this.taskOwner.getRandom().nextInt(this.chance) != 0) { return false; } else { Direction direction = this.taskOwner.getMotionDirection(); int i = direction.getStepX(); int j = direction.getStepZ(); BlockPos blockpos = this.taskOwner.blockPosition(); for(int k : JUMP_DISTANCES) { if (!this.isAirAbove(blockpos, i, j, k) || (this.safeJumping && !this.canJumpTo(blockpos, i, j, k))) { return false; } } return true; } } private boolean canJumpTo(BlockPos pos, int dx, int dz, int scale) { BlockPos blockpos = pos.offset(dx * scale, 0, dz * scale); return this.taskOwner.level.getFluidState(blockpos).is(FluidTags.WATER) && !this.taskOwner.level.getBlockState(blockpos).getMaterial().blocksMotion(); } private boolean isAirAbove(BlockPos pos, int dx, int dz, int scale) { return this.taskOwner.level.getBlockState(pos.offset(dx * scale, 1, dz * scale)).isAir() && this.taskOwner.level.getBlockState(pos.offset(dx * scale, 2, dz * scale)).isAir(); } public boolean canContinueToUse() { double d0 = this.taskOwner.getDeltaMovement().y; return (!(d0 * d0 < (double)0.03F) || this.taskOwner.getXRot() == 0.0F || !(Math.abs(this.taskOwner.getXRot()) < 10.0F) || !this.taskOwner.isInWater()) && !this.taskOwner.isOnGround(); } public boolean isInterruptable() { return false; } public void start() { Direction direction = this.taskOwner.getMotionDirection(); this.taskOwner.setDeltaMovement(this.taskOwner.getDeltaMovement().add((double)direction.getStepX() * 0.6D, 0.6D, (double)direction.getStepZ() * 0.6D)); this.taskOwner.getNavigation().stop(); } public void stop() { this.taskOwner.setXRot(0.0F); } public void tick() { boolean flag = this.inWater; if (!flag) { FluidState fluidstate = this.taskOwner.level.getFluidState(this.taskOwner.blockPosition()); this.inWater = fluidstate.is(FluidTags.WATER); } if (this.inWater && !flag) { this.taskOwner.playSound(SoundEvents.DOLPHIN_JUMP, 1.0F, 1.0F); } Vec3 vec3 = this.taskOwner.getDeltaMovement(); if (vec3.y * vec3.y < (double)0.03F && this.taskOwner.getXRot() != 0.0F) { this.taskOwner.setXRot(Mth.rotlerp(this.taskOwner.getXRot(), 0.0F, 0.2F)); } else if (vec3.length() > (double)1.0E-5F) { double d0 = vec3.horizontalDistance(); double d1 = Math.atan2(-vec3.y, d0) * (double)(180F / (float)Math.PI); this.taskOwner.setXRot((float)d1); } } }
3,822
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
FindItemsGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/FindItemsGoal.java
package untamedwilds.entity.ai; import net.minecraft.tags.ItemTags; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.Item; import net.minecraft.world.phys.AABB; import untamedwilds.entity.ComplexMobTerrestrial; import java.util.Comparator; import java.util.EnumSet; import java.util.List; public class FindItemsGoal extends Goal { private final ComplexMobTerrestrial taskOwner; private final ClosestSorter sorter; private final int distance; private ItemEntity targetItem; private FoodProperties targetItemStack; private final int executionChance; private final boolean hyperCarnivore; private final boolean hyperHerbivore; public FindItemsGoal(ComplexMobTerrestrial entityIn, int distance) { this(entityIn, distance, 100, false, false); } public FindItemsGoal(ComplexMobTerrestrial entityIn, int distance, boolean hyperCarnivore) { this(entityIn, distance, 100, hyperCarnivore, false); } public FindItemsGoal(ComplexMobTerrestrial entityIn, int distance, int chance, boolean hyperCarnivore, boolean hyperHerbivore) { this.taskOwner = entityIn; this.sorter = new ClosestSorter(entityIn); this.distance = distance; this.executionChance = chance; this.hyperCarnivore = hyperCarnivore; this.hyperHerbivore = hyperHerbivore; this.setFlags(EnumSet.of(Goal.Flag.MOVE, Flag.TARGET)); } public boolean canUse() { if (this.taskOwner.getHunger() > 80 || this.taskOwner.isBaby() || this.taskOwner.isSleeping()) { return false; } if (this.taskOwner.getRandom().nextInt(this.executionChance) != 0) { return false; } List<ItemEntity> list = this.taskOwner.level.getEntitiesOfClass(ItemEntity.class, this.getTargettableArea(distance)); list.removeIf((ItemEntity item) -> !item.getItem().isEdible()); if (!list.isEmpty()) { if (this.hyperCarnivore) { list.removeIf((ItemEntity item) -> !isMeat(item.getItem().getItem())); } else if (this.hyperHerbivore) { list.removeIf((ItemEntity item) -> isMeat(item.getItem().getItem())); } if (!list.isEmpty()) { list.sort(this.sorter); this.targetItem = list.get(0); this.targetItemStack = this.targetItem.getItem().getItem().getFoodProperties(); return true; } } return false; } private AABB getTargettableArea(double targetDistance) { return this.taskOwner.getBoundingBox().inflate(targetDistance, 4.0D, targetDistance); } private boolean isMeat(Item item) { if (item.getDefaultInstance().getItem().getFoodProperties() == null) { return false; } return item.getDefaultInstance().getItem().getFoodProperties().isMeat() || item.getDefaultInstance().is(ItemTags.FISHES); } @Override public void start() { this.taskOwner.getNavigation().moveTo(this.targetItem.getX(), this.targetItem.getY(), this.targetItem.getZ(), 1D); } @Override public boolean canContinueToUse() { if (this.targetItem == null || !this.targetItem.isAlive()) { return false; } else if (!this.taskOwner.canMove()) { return false; } return !this.taskOwner.isPathFinding(); } @Override public void tick() { double distance = Math.sqrt(Math.pow(this.taskOwner.getX() - this.targetItem.getX(), 2.0D) + Math.pow(this.taskOwner.getZ() - this.targetItem.getZ(), 2.0D)); if (distance < 1.5D) { this.taskOwner.addHunger(Math.max(targetItemStack.getNutrition() * 10, 10)); this.targetItem.getItem().shrink(1); this.taskOwner.setAnimation(taskOwner.getAnimationEat()); } if(this.taskOwner.getNavigation().isDone()){ stop(); } this.taskOwner.getNavigation().moveTo(this.targetItem.getX(), this.targetItem.getY(), this.targetItem.getZ(), 1D); } public static class ClosestSorter implements Comparator<Entity> { private final Entity entity; private ClosestSorter(Entity entityIn) { this.entity = entityIn; } public int compare(Entity entity_1, Entity entity_2) { double dist_1 = this.entity.distanceToSqr(entity_1); double dist_2 = this.entity.distanceToSqr(entity_2); if (dist_1 < dist_2) { return -1; } else { return dist_1 > dist_2 ? 1 : 0; } } } }
4,832
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
SmartLookAtGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/SmartLookAtGoal.java
package untamedwilds.entity.ai; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntitySelector; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.targeting.TargetingConditions; import net.minecraft.world.entity.player.Player; import untamedwilds.entity.ComplexMob; import java.util.EnumSet; public class SmartLookAtGoal extends Goal { protected final ComplexMob taskOwner; protected Entity closestEntity; protected final float maxDistance; private int lookTime; private final int chance; private double lookX; private double lookZ; protected final Class<? extends LivingEntity> watchedClass; protected final TargetingConditions SHOULD_LOOK; public SmartLookAtGoal(ComplexMob entityIn, Class<? extends LivingEntity> targetClass, float maxDistance) { this(entityIn, targetClass, maxDistance, 60); } public SmartLookAtGoal(ComplexMob entityIn, Class<? extends LivingEntity> targetClass, float maxDistance, int chanceIn) { this.taskOwner = entityIn; this.watchedClass = targetClass; this.maxDistance = maxDistance; this.chance = chanceIn; this.setFlags(EnumSet.of(Goal.Flag.LOOK)); if (targetClass == Player.class) { this.SHOULD_LOOK = TargetingConditions.forNonCombat().range(maxDistance).selector((p_25531_) -> EntitySelector.notRiding(entityIn).test(p_25531_)); } else { this.SHOULD_LOOK = TargetingConditions.forNonCombat().range(maxDistance); } } @Override public boolean canUse() { if (this.taskOwner.isSleeping()) { return false; } if (this.taskOwner.getRandom().nextInt(this.chance) != 0) { return false; } else { if (this.taskOwner.getTarget() != null) { this.closestEntity = this.taskOwner.getTarget(); } if (this.watchedClass == Player.class) { this.closestEntity = this.taskOwner.level.getNearestPlayer(this.SHOULD_LOOK, this.taskOwner, this.taskOwner.getX(), this.taskOwner.getY() + (double)this.taskOwner.getEyeHeight(), this.taskOwner.getZ()); } else { this.closestEntity = this.taskOwner.level.getNearestEntity(this.watchedClass, this.SHOULD_LOOK, this.taskOwner, this.taskOwner.getX(), this.taskOwner.getY() + (double)this.taskOwner.getEyeHeight(), this.taskOwner.getZ(), this.taskOwner.getBoundingBox().inflate(this.maxDistance, 3.0D, this.maxDistance)); } return this.closestEntity != null || this.taskOwner.getRandom().nextInt(20) != 0; } } @Override public boolean canContinueToUse() { /*if (!this.closestEntity.isAlive() || this.taskOwner.distanceToSqr(this.closestEntity) > (double)(this.maxDistance * this.maxDistance)) { return false; }*/ return this.lookTime > 0; } @Override public void start() { if (this.closestEntity == null) { double d0 = (Math.PI * 2D) * this.taskOwner.getRandom().nextDouble(); this.lookX = Math.cos(d0); this.lookZ = Math.sin(d0); this.lookTime = 20 + this.taskOwner.getRandom().nextInt(20); } this.lookTime = 40 + this.taskOwner.getRandom().nextInt(40); } @Override public void stop() { this.closestEntity = null; } @Override public void tick() { if (this.closestEntity == null) { this.taskOwner.getLookControl().setLookAt(this.taskOwner.getX() + this.lookX, this.taskOwner.getY() + (double)this.taskOwner.getEyeHeight(), this.taskOwner.getZ()); } else { this.taskOwner.getLookControl().setLookAt(this.closestEntity.getX(), this.closestEntity.getY() + (double)this.closestEntity.getEyeHeight(), this.closestEntity.getZ(), 20, this.taskOwner.getHeadRotSpeed()); } --this.lookTime; } }
4,027
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
AmphibiousTransition.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/AmphibiousTransition.java
package untamedwilds.entity.ai; import net.minecraft.world.entity.ai.behavior.BehaviorUtils; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.goal.RandomStrollGoal; import net.minecraft.world.entity.ai.util.LandRandomPos; import net.minecraft.world.phys.Vec3; import untamedwilds.entity.ComplexMobAmphibious; import javax.annotation.Nullable; import java.util.EnumSet; public class AmphibiousTransition extends RandomStrollGoal { private final ComplexMobAmphibious taskOwner; public AmphibiousTransition(ComplexMobAmphibious entityIn, double speedIn) { this(entityIn, speedIn, 120); } public AmphibiousTransition(ComplexMobAmphibious entityIn, double speedIn, int chance) { super(entityIn, speedIn, chance); this.taskOwner = entityIn; this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.JUMP)); } @Override public boolean canUse() { if (!taskOwner.canMove() || taskOwner.getTarget() != null /* && !taskOwner.getTarget().isInWater()*/) { return false; } return super.canUse(); } @Override public boolean canContinueToUse() { return !this.taskOwner.getNavigation().isDone(); } @Nullable protected Vec3 getPosition() { Vec3 vec3d = null; int rand = this.taskOwner.getRandom().nextInt(2); switch (rand) { case 0 -> { if (this.taskOwner.wantsToBeInWater()) vec3d = BehaviorUtils.getRandomSwimmablePos(this.taskOwner, 10, 7); } case 1 -> { if (this.taskOwner.wantsToBeOnLand()) vec3d = LandRandomPos.getPos(this.taskOwner, 10, 7); } } return vec3d; } }
1,782
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
JumpGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/JumpGoal.java
package untamedwilds.entity.ai; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.FluidTags; import net.minecraft.util.Mth; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.Vec3; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.ComplexMobAquatic; public class JumpGoal extends Goal { private static final int[] JUMP_DISTANCES = new int[]{0, 1, 3, 4}; // Vanilla implementation {0, 1, 4, 5, 6, 7} private final ComplexMob taskOwner; private final int chance; private boolean inWater; private final boolean safeJumping; public JumpGoal(ComplexMobAquatic entityIn, int chance) { this(entityIn, chance, true); } public JumpGoal(ComplexMobAquatic entityIn, int chance, boolean safeJumping) { this.taskOwner = entityIn; this.chance = chance; this.safeJumping = safeJumping; } public boolean canUse() { if (this.taskOwner.getRandom().nextInt(this.chance) != 0) { return false; } else { Direction direction = this.taskOwner.getMotionDirection(); int i = direction.getStepX(); int j = direction.getStepZ(); BlockPos blockpos = this.taskOwner.blockPosition(); for(int k : JUMP_DISTANCES) { if (!this.isAirAbove(blockpos, i, j, k) || (this.safeJumping && !this.canJumpTo(blockpos, i, j, k))) { return false; } } return true; } } private boolean canJumpTo(BlockPos pos, int dx, int dz, int scale) { BlockPos blockpos = pos.offset(dx * scale, 0, dz * scale); return this.taskOwner.level.getFluidState(blockpos).is(FluidTags.WATER) && !this.taskOwner.level.getBlockState(blockpos).getMaterial().blocksMotion(); } private boolean isAirAbove(BlockPos pos, int dx, int dz, int scale) { return this.taskOwner.level.getBlockState(pos.offset(dx * scale, 1, dz * scale)).isAir() && this.taskOwner.level.getBlockState(pos.offset(dx * scale, 2, dz * scale)).isAir(); } public boolean canContinueToUse() { double d0 = this.taskOwner.getDeltaMovement().y; return (!(d0 * d0 < (double)0.03F) || this.taskOwner.getXRot() == 0.0F || !(Math.abs(this.taskOwner.getXRot()) < 10.0F) || !this.taskOwner.isInWater()) && !this.taskOwner.isOnGround(); } public boolean isInterruptable() { return false; } public void start() { Direction direction = this.taskOwner.getMotionDirection(); this.taskOwner.setDeltaMovement(this.taskOwner.getDeltaMovement().add((double)direction.getStepX() * 0.6D, 0.6D, (double)direction.getStepZ() * 0.6D)); this.taskOwner.getNavigation().stop(); } public void stop() { this.taskOwner.setXRot(0.0F); } public void tick() { boolean flag = this.inWater; if (!flag) { FluidState fluidstate = this.taskOwner.level.getFluidState(this.taskOwner.blockPosition()); this.inWater = fluidstate.is(FluidTags.WATER); } if (this.inWater && !flag) { this.taskOwner.playSound(SoundEvents.GOAT_LONG_JUMP, 1.0F, 1.0F); } Vec3 vec3 = this.taskOwner.getDeltaMovement(); if (vec3.y * vec3.y < (double)0.03F && this.taskOwner.getXRot() != 0.0F) { this.taskOwner.setXRot(Mth.rotlerp(this.taskOwner.getXRot(), 0.0F, 0.2F)); } else if (vec3.length() > (double)1.0E-5F) { double d0 = vec3.horizontalDistance(); double d1 = Math.atan2(-vec3.y, d0) * (double)(180F / (float)Math.PI); this.taskOwner.setXRot((float)d1); } } }
3,838
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
MeleeAttackCircleHerd.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/MeleeAttackCircleHerd.java
package untamedwilds.entity.ai; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.targeting.TargetingConditions; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.pathfinder.Node; import net.minecraft.world.level.pathfinder.Path; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import untamedwilds.entity.ComplexMob; import untamedwilds.util.EntityUtils; import java.util.EnumSet; import java.util.Optional; import java.util.Random; public class MeleeAttackCircleHerd extends Goal { protected final ComplexMob attacker; protected int attackTick; private final double speedTowardsTarget; private final boolean longMemory; private Path path; private int delayCounter; private double targetX; private double targetY; private double targetZ; private final float extraReach; private long field_220720_k; private int failedPathFindingPenalty = 0; private final boolean canPenalize = false; private float offset = 0; private final float maxJumpVelocity; private final boolean isJumper; public MeleeAttackCircleHerd(ComplexMob entityIn, double speedIn, boolean useLongMemory) { this(entityIn, speedIn, useLongMemory, 0); } public MeleeAttackCircleHerd(ComplexMob entityIn, double speedIn, boolean useLongMemory, float reach) { this(entityIn, speedIn, useLongMemory, reach, false); } public MeleeAttackCircleHerd(ComplexMob entityIn, double speedIn, boolean useLongMemory, float reach, boolean isJumper) { this.attacker = entityIn; this.speedTowardsTarget = speedIn; this.longMemory = useLongMemory; this.extraReach = reach; this.isJumper = isJumper; this.maxJumpVelocity = 1; this.setFlags(EnumSet.of(Flag.MOVE, Flag.TARGET, Flag.LOOK)); } @Override public boolean canUse() { if (this.attacker.isBaby()) { return false; } long i = this.attacker.level.getGameTime(); if (i - this.field_220720_k < 20L) { return false; } else { this.field_220720_k = i; LivingEntity livingentity = this.attacker.getTarget(); if (livingentity == null) { return false; } else if (!livingentity.isAlive()) { return false; } else { if (canPenalize) { if (--this.delayCounter <= 0) { this.path = this.attacker.getNavigation().createPath(livingentity, 0); this.delayCounter = 4 + this.attacker.getRandom().nextInt(7); return this.path != null; } else { return true; } } this.path = this.attacker.getNavigation().createPath(livingentity, 0); return this.path != null; } } } @Override public boolean canContinueToUse() { LivingEntity livingentity = this.attacker.getTarget(); if (livingentity == null || (this.attacker.getAirSupply() < 40 && !this.attacker.canBreatheUnderwater()) || !livingentity.isAlive()) { return false; } else if (!this.longMemory) { return !this.attacker.getNavigation().isDone(); } else if (!this.attacker.isWithinRestriction(livingentity.blockPosition())) { return false; } else { return !(livingentity instanceof Player) || !livingentity.isSpectator() && !((Player)livingentity).isCreative(); } } public void start() { this.attacker.getNavigation().moveTo(this.path, this.speedTowardsTarget); this.attacker.setAggressive(true); this.delayCounter = 0; } public void stop() { LivingEntity livingentity = this.attacker.getTarget(); if (!TargetingConditions.forCombat().test(this.attacker, livingentity)) { this.attacker.setTarget(null); } this.attacker.setAggressive(false); this.attacker.getNavigation().stop(); } public void tick() { LivingEntity livingentity = this.attacker.getTarget(); if (this.attacker.tickCount % 200 == 0) { this.offset = this.attacker.getRandom().nextInt(10); } if (this.attacker.herd.creatureList.size() == 1 || (this.attacker.tickCount % 200 < 61 && this.attacker.getTarget().getLastHurtByMob() != this.attacker)) { this.attacker.getLookControl().setLookAt(livingentity, 30.0F, 30.0F); double d0 = this.attacker.distanceToSqr(livingentity.getX(), livingentity.getBoundingBox().minY, livingentity.getZ()); --this.delayCounter; if ((this.longMemory || this.attacker.getSensing().hasLineOfSight(livingentity)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || livingentity.distanceToSqr(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRandom().nextFloat() < 0.05F)) { this.targetX = livingentity.getX(); this.targetY = livingentity.getBoundingBox().minY; this.targetZ = livingentity.getZ(); this.delayCounter = 4 + this.attacker.getRandom().nextInt(7); if (this.canPenalize) { this.delayCounter += failedPathFindingPenalty; if (this.attacker.getNavigation().getPath() != null) { Node finalPathPoint = this.attacker.getNavigation().getPath().getEndNode(); if (finalPathPoint != null && livingentity.distanceToSqr(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z) < 1) failedPathFindingPenalty = 0; else failedPathFindingPenalty += 10; } else { failedPathFindingPenalty += 10; } } if (d0 > 1024.0D) { this.delayCounter += 10; } else if (d0 > 256.0D) { this.delayCounter += 5; } if (!this.attacker.getNavigation().moveTo(livingentity, this.speedTowardsTarget)) { this.delayCounter += 15; } } } else if (this.attacker.herd != null) { if (this.attacker.getTarget() != null) { double x = this.attacker.getTarget().getX() + Math.cos(this.offset + this.attacker.tickCount / 40F) * 6; double z = this.attacker.getTarget().getZ() + Math.sin(this.offset + this.attacker.tickCount / 40F) * 6; this.attacker.getNavigation().moveTo(x, this.attacker.getTarget().getY(), z, 1.2F); } } BlockPos forwardNearPos = EntityUtils.getRelativeBlockPos(this.attacker, 1.2F, 0); if (this.isJumper && this.attacker.isOnGround() && this.attacker.getLevel().getBlockState(forwardNearPos.below()).isAir() && this.attacker.getLevel().getBlockState(forwardNearPos.below(2)).isAir() && this.attacker.getSensing().hasLineOfSight(livingentity)) { BlockPos forwardFarPos = EntityUtils.getRelativeBlockPos(this.attacker, 5F, 0); if (new Vec3(forwardFarPos.getX(), forwardFarPos.getY(), forwardFarPos.getZ()).distanceTo(livingentity.getPosition(0)) < this.attacker.getPosition(0).distanceTo(livingentity.getPosition(0))) { //this.attacker.getEntityWorld().setBlockState(targetpos, Blocks.TORCH.defaultBlockState()); Random rand = this.attacker.getRandom(); for (int i = 0; i < 4; i++) { forwardFarPos.offset(rand.nextInt(2) - 1, rand.nextInt(2) - 1, rand.nextInt(2) - 1); if (this.attacker.getNavigation().isStableDestination(forwardFarPos)) { Optional<Vec3> jump_vec = this.calculateOptimalJumpVector(this.attacker, Vec3.atCenterOf(forwardFarPos)); if (jump_vec.isPresent()) { double d1 = jump_vec.get().length(); double d2 = 1 + d1 + (this.attacker.hasEffect(MobEffects.JUMP) ? (double)(0.1F * (float)(this.attacker.getEffect(MobEffects.JUMP).getAmplifier() + 1)) : 0.0D); this.attacker.setDeltaMovement(jump_vec.get().x * d2 / d1, jump_vec.get().y, jump_vec.get().z * d2 / d1); this.attacker.getNavigation().stop(); break; } } } } } this.attackTick = Math.max(this.attackTick - 1, 0); this.checkAndPerformAttack(livingentity, this.attacker.distanceToSqr(this.targetX, this.targetY, this.targetZ)); } protected void checkAndPerformAttack(LivingEntity enemy, double distToEnemySqr) { double d0 = this.getAttackReachSqr(enemy); if (this.attacker.hasLineOfSight(enemy) && distToEnemySqr <= d0 && this.attackTick <= 0) { this.attackTick = 20; this.attacker.doHurtTarget(enemy); } } protected double getAttackReachSqr(LivingEntity attackTarget) { return (this.attacker.getBbWidth() * 2.0F * this.attacker.getBbWidth() * 2.0F + attackTarget.getBbWidth() + this.extraReach); } // Start of the code gore private Optional<Vec3> calculateOptimalJumpVector(PathfinderMob entityIn, Vec3 targetIn) { return calculateOptimalJumpVector(entityIn, targetIn, 20, 55); // 65, 85 are original Goat params } private Optional<Vec3> calculateOptimalJumpVector(PathfinderMob entityIn, Vec3 targetIn, int minAngleIn, int maxAngleIn) { Optional<Vec3> optional = Optional.empty(); for(int i = minAngleIn; i < maxAngleIn; i += 5) { Optional<Vec3> optional1 = this.calculateJumpVectorForAngle(entityIn, targetIn, i); if (optional.isEmpty() || optional1.isPresent() && optional1.get().lengthSqr() < optional.get().lengthSqr()) optional = optional1; } return optional; } private Optional<Vec3> calculateJumpVectorForAngle(PathfinderMob entityIn, Vec3 targetIn, int angleIn) { Vec3 entityPos = entityIn.position(); Vec3 vec31 = (new Vec3(targetIn.x - entityPos.x, 0.0D, targetIn.z - entityPos.z)).normalize().scale(0.5D); targetIn = targetIn.subtract(vec31); Vec3 vec32 = targetIn.subtract(entityPos); float angleRad = (float)angleIn * (float)Math.PI / 180.0F; double d1 = vec32.subtract(0.0D, vec32.y, 0.0D).lengthSqr(); double d2 = Math.sqrt(d1); double d3 = vec32.y; double d4 = Math.sin((2.0F * angleRad)); double d6 = Math.pow(Math.cos(angleRad), 2.0D); double d11 = d1 * 0.08D / (d2 * d4 - 2.0D * d3 * d6); if (d11 < 0.0D) return Optional.empty(); else { double d7 = Math.sin(angleRad); double d8 = Math.cos(angleRad); double d0 = Math.atan2(vec32.z, vec32.x); double d9 = Math.sin(d0); double d10 = Math.cos(d0); double d12 = Math.sqrt(d11); if (d12 > (double)this.maxJumpVelocity) return Optional.empty(); else { double d13 = d12 * d8; double d14 = d12 * d7; int i = Mth.ceil(d2 / d13) * 2; double d15 = 0.0D; Vec3 vec33 = null; for(int j = 0; j < i - 1; ++j) { d15 += d2 / (double)i; double d16 = d7 / d8 * d15 - Math.pow(d15, 2.0D) * 0.08D / (2.0D * d11 * Math.pow(d8, 2.0D)); double d17 = d15 * d10; double d18 = d15 * d9; Vec3 vec34 = new Vec3(entityPos.x + d17, entityPos.y + d16, entityPos.z + d18); if (vec33 != null && !this.isClearTransition(entityIn, vec33, vec34)) { return Optional.empty(); } vec33 = vec34; } return Optional.of((new Vec3(d13 * d10, d14, d13 * d9)).scale(0.95F)); } } } private boolean isClearTransition(Mob entityIn, Vec3 p_147665_, Vec3 p_147666_) { EntityDimensions entitydimensions = entityIn.getDimensions(Pose.LONG_JUMPING); Vec3 vec3 = p_147666_.subtract(p_147665_); double d0 = Math.min(entitydimensions.width, entitydimensions.height); int i = Mth.ceil(vec3.length() / d0); Vec3 vec31 = vec3.normalize(); Vec3 vec32 = p_147665_; for(int j = 0; j < i; ++j) { vec32 = j == i - 1 ? p_147666_ : vec32.add(vec31.scale(d0 * (double)0.9F)); AABB aabb = entitydimensions.makeBoundingBox(vec32); if (!entityIn.level.noCollision(entityIn, aabb)) { return false; } } return true; } }
13,263
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
SmartFollowOwnerGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/SmartFollowOwnerGoal.java
package untamedwilds.entity.ai; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.navigation.FlyingPathNavigation; import net.minecraft.world.entity.ai.navigation.GroundPathNavigation; import net.minecraft.world.entity.ai.navigation.PathNavigation; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.level.pathfinder.WalkNodeEvaluator; import untamedwilds.entity.ComplexMob; import java.util.EnumSet; public class SmartFollowOwnerGoal extends Goal { protected final ComplexMob taskOwner; private LivingEntity owner; protected final Level level; private final double followSpeed; private final PathNavigation navigator; private int timeToRecalcPath; private final float maxDist; private final float minDist; private float oldWaterCost; public SmartFollowOwnerGoal(ComplexMob entityIn, double speedIn, float minDistIn, float maxDistIn) { this.taskOwner = entityIn; this.level = taskOwner.level; this.followSpeed = speedIn; this.navigator = entityIn.getNavigation(); this.minDist = minDistIn; this.maxDist = maxDistIn; this.setFlags(EnumSet.of(Flag.MOVE, Flag.LOOK)); if (!(entityIn.getNavigation() instanceof GroundPathNavigation) && !(entityIn.getNavigation() instanceof FlyingPathNavigation)) { throw new IllegalArgumentException("Unsupported mob type for SmartFollowOwnerGoal"); } } @Override public boolean canUse() { LivingEntity owner = this.taskOwner.getOwner(); if (owner == null || owner.isSpectator() || !this.taskOwner.canMove() || this.taskOwner.distanceToSqr(owner) < (double)(this.minDist * this.minDist)) { return false; } this.owner = owner; return this.taskOwner.getCommandInt() == 1; } @Override public boolean canContinueToUse() { return !this.navigator.isDone() && this.taskOwner.distanceToSqr(this.owner) > (double)(this.maxDist * this.maxDist) && !this.taskOwner.isSitting(); } @Override public void start() { this.timeToRecalcPath = 0; this.oldWaterCost = this.taskOwner.getPathfindingMalus(BlockPathTypes.WATER); this.taskOwner.setPathfindingMalus(BlockPathTypes.WATER, 0.0F); } @Override public void stop() { this.owner = null; this.navigator.stop(); this.taskOwner.setPathfindingMalus(BlockPathTypes.WATER, this.oldWaterCost); } @Override public void tick() { this.taskOwner.getLookControl().setLookAt(this.owner, 10.0F, (float)this.taskOwner.getHeadRotSpeed()); if (this.taskOwner.canMove() && this.taskOwner.getCommandInt() == 1) { if (--this.timeToRecalcPath <= 0) { this.timeToRecalcPath = 10; if (!this.taskOwner.isLeashed() && !this.taskOwner.isPassenger()) { if (!this.navigator.moveTo(this.owner, this.followSpeed)) { if (this.taskOwner.distanceToSqr(this.owner) >= 225.0D && this.taskOwner.getTarget() == null) { this.teleportToOwner(); } } } } } } private void teleportToOwner() { BlockPos blockpos = this.owner.blockPosition(); for(int i = 0; i < 10; ++i) { int j = this.randomIntInclusive(-3, 3); int k = this.randomIntInclusive(-1, 1); int l = this.randomIntInclusive(-3, 3); boolean flag = this.maybeTeleportTo(blockpos.getX() + j, blockpos.getY() + k, blockpos.getZ() + l); if (flag) { return; } } } private boolean maybeTeleportTo(int p_25304_, int p_25305_, int p_25306_) { if (Math.abs((double)p_25304_ - this.owner.getX()) < 2.0D && Math.abs((double)p_25306_ - this.owner.getZ()) < 2.0D) { return false; } else if (!this.canTeleportTo(new BlockPos(p_25304_, p_25305_, p_25306_))) { return false; } else { this.taskOwner.moveTo((double)p_25304_ + 0.5D, p_25305_, (double)p_25306_ + 0.5D, this.taskOwner.getYRot(), this.taskOwner.getXRot()); this.taskOwner.getNavigation().stop(); return true; } } private boolean canTeleportTo(BlockPos p_25308_) { BlockPathTypes blockpathtypes = WalkNodeEvaluator.getBlockPathTypeStatic(this.level, p_25308_.mutable()); if (blockpathtypes != BlockPathTypes.WALKABLE) { return false; } else { BlockState blockstate = this.level.getBlockState(p_25308_.below()); if (/*!this.canFly && */blockstate.getBlock() instanceof LeavesBlock) { return false; } else { BlockPos blockpos = p_25308_.subtract(this.taskOwner.blockPosition()); return this.level.noCollision(this.taskOwner, this.taskOwner.getBoundingBox().inflate(1, 0, 1).move(blockpos)); } } } private int randomIntInclusive(int p_25301_, int p_25302_) { return this.taskOwner.getRandom().nextInt(p_25302_ - p_25301_ + 1) + p_25301_; } }
5,506
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
FollowParentGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/FollowParentGoal.java
package untamedwilds.entity.ai; import net.minecraft.world.entity.ai.goal.Goal; import untamedwilds.entity.ComplexMob; import java.util.EnumSet; import java.util.List; public class FollowParentGoal extends Goal { private final ComplexMob taskOwner; private ComplexMob parentAnimal; private final double moveSpeed; private int delayCounter; public FollowParentGoal(ComplexMob entityIn, double speedIn) { this.taskOwner = entityIn; this.moveSpeed = speedIn; this.setFlags(EnumSet.of(Flag.MOVE, Flag.TARGET)); } @Override public boolean canUse() { if (!this.taskOwner.isBaby() || this.taskOwner.getTarget() != null || !this.taskOwner.canMove()) { return false; } List<? extends ComplexMob> list = this.taskOwner.level.getEntitiesOfClass(this.taskOwner.getClass(), this.taskOwner.getBoundingBox().inflate(8.0D, 4.0D, 8.0D)); ComplexMob entityanimal = null; double d0 = Double.MAX_VALUE; for (ComplexMob entityanimal1 : list) { if (!entityanimal1.isBaby() && (entityanimal1.getVariant() == this.taskOwner.getVariant())) { double d1 = this.taskOwner.distanceToSqr(entityanimal1); if (d1 <= d0) { d0 = d1; entityanimal = entityanimal1; } } } if (entityanimal == null) { return false; } else if (d0 < 9.0D) { return false; } else { this.parentAnimal = entityanimal; return true; } } @Override public boolean canContinueToUse() { if (this.taskOwner.getAge() >= 0) { return false; } else if (!this.parentAnimal.isAlive()) { return false; } else { double d0 = this.taskOwner.distanceToSqr(this.parentAnimal); return d0 >= 9.0D && d0 <= 256.0D; } } @Override public void start() { this.delayCounter = 0; } @Override public void stop() { this.parentAnimal = null; } @Override public void tick() { if (--this.delayCounter <= 0) { this.delayCounter = 10; this.taskOwner.getNavigation().moveTo(this.parentAnimal, this.moveSpeed); } } }
2,375
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
GotoSleepGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/GotoSleepGoal.java
package untamedwilds.entity.ai; import com.mojang.math.Vector3f; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.level.pathfinder.Node; import net.minecraft.world.level.pathfinder.Path; import untamedwilds.entity.ComplexMobAmphibious; import untamedwilds.entity.ComplexMobTerrestrial; import javax.annotation.Nullable; import java.util.EnumSet; import java.util.Random; public class GotoSleepGoal extends Goal { private final ComplexMobTerrestrial creature; protected Vector3f target; private final int executionChance; private final double speed; private final boolean usesHome; public GotoSleepGoal(ComplexMobTerrestrial entityIn, double speedIn) { this(entityIn, speedIn, 200, true); } public GotoSleepGoal(ComplexMobTerrestrial entityIn, double speedIn, int chance) { this(entityIn, speedIn, chance, true); } public GotoSleepGoal(ComplexMobTerrestrial entityIn, double speedIn, int chance, boolean usesHome) { this.creature = entityIn; this.speed = speedIn; this.executionChance = chance; this.usesHome = usesHome; this.setFlags(EnumSet.of(Goal.Flag.MOVE, Flag.JUMP)); } @Override public boolean canUse() { // Common checks if (this.creature.getRandom().nextInt(this.executionChance) != 0 || this.creature.forceSleep < 0 || this.creature.getTarget() != null || (this.creature.isTame() && this.creature.getCommandInt() != 0)) { return false; } // Wake up checks if (this.creature.isSleeping() && (this.creature.forceSleep <= 0 || (!(this.creature instanceof ComplexMobAmphibious) && this.creature.isInWater()))) { this.creature.setSleeping(false); return false; } // Valid sleep checks if (this.creature.getCommandInt() != 0 || this.creature.isActive() || !this.creature.canMove() || (this.creature.isInWater() && !(this.creature instanceof ComplexMobAmphibious))) { return false; } if (isValidShelter(this.creature.blockPosition()) || !this.usesHome) { this.creature.setHome(this.creature.blockPosition()); this.creature.setSleeping(true); return false; } if (this.creature.getHome() == BlockPos.ZERO || !canEasilyReach(this.creature.getHome()) || this.creature.distanceToSqr(this.creature.getHomeAsVec()) > 100000) { this.creature.setHome(BlockPos.ZERO); BlockPos pos = this.checkForNewHome(); if (pos == null) { return false; } else { this.creature.setHome(pos); } } this.target = new Vector3f(this.creature.getHomeAsVec()); return true; } private boolean canEasilyReach(BlockPos target) { //this.targetSearchDelay = 10 + this.creature.getRandom().nextInt(5); Path path = this.creature.getNavigation().createPath(target, 0); if (path == null) { return false; } else { Node pathpoint = path.getEndNode(); if (pathpoint == null) { return false; } else { int i = pathpoint.x - Mth.floor(target.getX()); int j = pathpoint.z - Mth.floor(target.getZ()); return (double)(i * i + j * j) <= 2.25D; } } } @Override public void start() { this.creature.getNavigation().moveTo(this.target.x(), this.target.y(), this.target.z(), this.speed); } @Override public boolean canContinueToUse() { return !this.creature.getNavigation().isDone(); } @Nullable public BlockPos checkForNewHome() { Random random = this.creature.getRandom(); BlockPos blockpos = this.creature.blockPosition(); for(int i = 0; i < 10; ++i) { BlockPos blockpos1 = blockpos.offset(random.nextInt(12) - 6, random.nextInt(4) - 2, random.nextInt(12) - 6); if (isValidShelter(blockpos1) && this.creature.getWalkTargetValue(blockpos1) < 0.0F) { return blockpos1; } } return null; } private boolean isValidShelter(BlockPos blockPos) { // We consider a valid shelter a dark location, with Sky Light Level less than 14 (mostly, to prevent mobs sleeping under broad daylight) return !this.creature.level.canSeeSky(blockPos); //return this.creature.level.getLightFor(LightType.SKY, blockPos) <= 14; // Was 12 } }
4,626
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
RaidCropsGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/RaidCropsGoal.java
package untamedwilds.entity.ai; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.CropBlock; import net.minecraft.world.level.block.FarmBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.storage.loot.LootContext; import untamedwilds.entity.ComplexMobTerrestrial; import java.util.EnumSet; import java.util.List; public class RaidCropsGoal extends Goal { private BlockPos targetPos; private final ComplexMobTerrestrial taskOwner; private boolean continueTask; public RaidCropsGoal(ComplexMobTerrestrial entityIn) { this.taskOwner = entityIn; this.continueTask = true; this.setFlags(EnumSet.of(Goal.Flag.MOVE)); } @Override public boolean canUse() { if (this.taskOwner.isTame() || !net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.taskOwner.level, this.taskOwner)) { return false; } if (this.taskOwner.getHunger() > 80 || this.taskOwner.getTarget() != null) { return false; } if (this.taskOwner.getRandom().nextInt(120) != 0) { return false; } BlockPos pos = this.taskOwner.blockPosition(); this.targetPos = getNearbyFarmland(pos); return this.targetPos != null; } @Override public void start() { this.taskOwner.getNavigation().moveTo((double)this.targetPos.getX() + 0.5D, this.targetPos.getY() + 1, (double)this.targetPos.getZ() + 0.5D, 1f); } @Override public void tick() { if (this.taskOwner.distanceToSqr(targetPos.getX(), targetPos.getY(), targetPos.getZ()) < 4) { BlockState block = this.taskOwner.level.getBlockState(this.targetPos); if (block.getBlock() instanceof CropBlock) { // TODO: Broken LootContext.Builder loot = new LootContext.Builder((ServerLevel) taskOwner.level).withRandom(this.taskOwner.getRandom()).withLuck(1.0F); List<ItemStack> drops = block.getBlock().getDrops(block, loot); if (!drops.isEmpty()) { this.taskOwner.addHunger(Math.max(drops.size() * 10, 10)); this.taskOwner.level.destroyBlock(this.targetPos, false); this.taskOwner.getNavigation().stop(); } } this.continueTask = false; } } @Override public boolean canContinueToUse() { if (this.taskOwner.getHunger() > 80 || this.taskOwner.level.isEmptyBlock(this.targetPos)) { return false; } return this.continueTask; } private BlockPos getNearbyFarmland(BlockPos roomCenter) { int X = 15; int Y = 3; //List<BlockPos> inventories = new ArrayList<>(); for (BlockPos blockpos : BlockPos.betweenClosed(roomCenter.offset(-X, -Y, -X), roomCenter.offset(X, Y, X))) { if (this.taskOwner.level.getBlockState(blockpos).getBlock() instanceof FarmBlock) { if (this.hasPlantedCrop(this.taskOwner.level, blockpos)) { return blockpos.above(); } } } return null; } private boolean hasPlantedCrop(LevelReader worldIn, BlockPos pos) { BlockState block = worldIn.getBlockState(pos.above()); return block.getBlock() instanceof CropBlock; } }
3,592
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
LayEggsOnNestGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/LayEggsOnNestGoal.java
package untamedwilds.entity.ai; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.ai.goal.MoveToBlockGoal; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import untamedwilds.block.blockentity.ReptileNestBlockEntity; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.INestingMob; import untamedwilds.init.ModBlock; import javax.annotation.Nullable; import java.util.EnumSet; import java.util.Random; public class LayEggsOnNestGoal extends MoveToBlockGoal { private final ComplexMob taskOwner; private final Level world; private boolean hasReachedDestination; private boolean needsToBuildNest = false; private int nestBuildingTicks; public LayEggsOnNestGoal(ComplexMob entityIn) { super(entityIn, 1, 16, 4); this.taskOwner = entityIn; this.world = entityIn.level; this.setFlags(EnumSet.of(Flag.MOVE, Flag.JUMP)); } @Override public boolean canUse() { if (!(this.taskOwner instanceof INestingMob) || !((INestingMob)taskOwner).wantsToLayEggs()) return false; if (this.nextStartTick > 0) { --this.nextStartTick; return false; } else { needsToBuildNest = false; this.nextStartTick = this.nextStartTick(this.mob); if (this.findNearestBlock()) return true; needsToBuildNest = true; return this.checkForNewNest(); } } public boolean canContinueToUse() { return ((INestingMob)this.taskOwner).wantsToLayEggs() && super.canContinueToUse(); } @Override public double acceptedDistance() { return 1.0D; } public void tick() { super.tick(); BlockPos blockpos = this.getMoveToTarget(); if (!isWithinXZDist(blockpos, this.mob.position(), this.acceptedDistance())) { this.hasReachedDestination = false; ++this.tryTicks; if (this.shouldRecalculatePath()) { this.mob.getNavigation().moveTo((double) ((float) blockpos.getX()) + 0.5D, blockpos.getY(), (double) ((float) blockpos.getZ()) + 0.5D, this.speedModifier); } } else { this.hasReachedDestination = true; --this.tryTicks; } //((ServerLevel)this.taskOwner.level).sendParticles(ParticleTypes.ANGRY_VILLAGER, blockpos.getX(), blockpos.getY(), blockpos.getZ(), 20, 0.0D, 0.0D, 0.0D, 0.15F); if (this.isReachedTarget()) { if (this.needsToBuildNest) { --this.nestBuildingTicks; if (this.nestBuildingTicks % 30 == 0) { ((ServerLevel)this.taskOwner.level).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, this.taskOwner.level.getBlockState(this.blockPos.below())), this.taskOwner.getX(), this.taskOwner.getY(), this.taskOwner.getZ(), 20, 0.0D, 0.0D, 0.0D, 0.15F); this.taskOwner.playSound(SoundEvents.SHOVEL_FLATTEN, 0.8F, 0.6F); } if (this.nestBuildingTicks <= 0) { this.world.setBlock(this.blockPos, ModBlock.NEST_REPTILE.get().defaultBlockState(), 2); ReptileNestBlockEntity te = (ReptileNestBlockEntity) world.getBlockEntity(this.blockPos); if (te != null) { te.setEntityType(this.taskOwner.getType()); te.setVariant(this.taskOwner.getVariant()); te.setEggCount(0); } this.needsToBuildNest = false; } } else { this.addEggsToNest(); stop(); } } } @Nullable public boolean checkForNewNest() { Random random = this.taskOwner.getRandom(); BlockPos blockpos = this.taskOwner.blockPosition(); for(int i = 0; i < 10; ++i) { BlockPos blockpos1 = blockpos.offset(random.nextInt(8) - 4, random.nextInt(4) - 2, random.nextInt(8) - 4); if (((INestingMob)this.taskOwner).isValidNestBlock(blockpos1) && this.isValidTarget(this.mob.level, blockpos1)) { this.nestBuildingTicks = 400 + this.taskOwner.getRandom().nextInt(300); this.blockPos = blockpos1; return true; } } return false; } private void addEggsToNest() { BlockState blockstate = taskOwner.level.getBlockState(this.blockPos); if (blockstate.is(ModBlock.NEST_REPTILE.get())) { if (taskOwner.level.getBlockEntity(this.blockPos) instanceof ReptileNestBlockEntity nest) { //UntamedWilds.LOGGER.info("Adding eggs to existing nest"); if (((INestingMob)this.taskOwner).wantsToLayEggs()) nest.setEggCount(nest.getEggCount() + this.taskOwner.getOffspring()); taskOwner.level.updateNeighbourForOutputSignal(this.blockPos, blockstate.getBlock()); ((INestingMob)taskOwner).setEggStatus(false); } } } private boolean isWithinXZDist(BlockPos blockpos, Vec3 positionVec, double distance) { return blockpos.distSqr(new BlockPos(positionVec.x(), blockpos.getY(), positionVec.z())) < distance * distance; } protected boolean isReachedTarget() { return this.hasReachedDestination; } @Override protected boolean isValidTarget(LevelReader worldIn, BlockPos pos) { if (this.needsToBuildNest) { //((ServerLevel)this.taskOwner.level).sendParticles(ParticleTypes.HAPPY_VILLAGER, pos.getX(), pos.getY(), pos.getZ(), 20, 0.0D, 0.0D, 0.0D, 0.15F); return ((INestingMob)this.taskOwner).isValidNestBlock(pos); } return worldIn.getBlockState(pos).is(ModBlock.NEST_REPTILE.get()) && worldIn.getBlockEntity(pos) instanceof ReptileNestBlockEntity && ((ReptileNestBlockEntity) worldIn.getBlockEntity(pos)).getVariant() == this.taskOwner.getVariant(); } }
6,337
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
GrazeGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/GrazeGoal.java
package untamedwilds.entity.ai; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.ComplexMobTerrestrial; import untamedwilds.init.ModTags; import javax.annotation.Nullable; import java.util.EnumSet; import java.util.Random; // TODO: Fix this shit so mobs actually walk to a grazeable pos public class GrazeGoal extends Goal { private final ComplexMobTerrestrial taskOwner; public final Level entityWorld; public BlockPos testpos; private int eatingGrassTimer; private final int executionChance; public GrazeGoal(ComplexMobTerrestrial entityIn, int chance) { this.taskOwner = entityIn; this.entityWorld = entityIn.level; this.executionChance = chance; this.setFlags(EnumSet.of(Flag.MOVE, Flag.LOOK, Flag.JUMP)); } @Override public boolean canUse() { if (!this.taskOwner.canMove() || this.taskOwner.isBaby() || this.taskOwner.getHunger() > 100 || this.taskOwner.getTarget() != null || this.taskOwner.getRandom().nextInt(executionChance) != 0) { return false; } this.testpos = this.taskOwner.blockPosition().offset(Math.cos(Math.toRadians(this.taskOwner.getYRot()+ 90)) * 1.2, 0, Math.sin(Math.toRadians(this.taskOwner.getYRot() + 90)) * 1.2); //this.testpos = new BlockPos(this.taskOwner.getPosition()); if (this.isGrazeable()) { return true; } if (this.taskOwner.getHunger() < 40) { BlockPos pos = this.locateGrazeables(); if (pos != null) { this.taskOwner.getNavigation().moveTo(pos.getX(), pos.getY(),pos.getZ(), 1); } } return false; } @Override public void start() { this.eatingGrassTimer = 40; this.entityWorld.broadcastEntityEvent(this.taskOwner, (byte)10); this.taskOwner.getNavigation().stop(); this.taskOwner.setAnimation(this.taskOwner.getAnimationEat()); } @Override public void stop() { this.eatingGrassTimer = 0; } @Override public boolean canContinueToUse() { return this.eatingGrassTimer > 0; } @Override public void tick() { this.eatingGrassTimer = Math.max(0, this.eatingGrassTimer - 1); if (this.eatingGrassTimer == 4) { if (this.entityWorld.getBlockState(this.testpos).is(ModTags.ModBlockTags.GRAZEABLE_BLOCKS)) { if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.entityWorld, this.taskOwner) && ConfigGamerules.grazerGriefing.get()) { this.entityWorld.destroyBlock(this.testpos, false); } this.taskOwner.addHunger(16); this.taskOwner.ate(); } else { BlockPos blockpos1 = this.testpos.below(); if (this.entityWorld.getBlockState(blockpos1).getBlock() == Blocks.GRASS_BLOCK) { if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.entityWorld, this.taskOwner)) { this.entityWorld.globalLevelEvent(2001, blockpos1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); if (ConfigGamerules.grazerGriefing.get()) { this.entityWorld.setBlock(blockpos1, Blocks.DIRT.defaultBlockState(), 2); } } this.taskOwner.addHunger(16); this.taskOwner.ate(); } } } } @Nullable private BlockPos locateGrazeables() { Random random = this.taskOwner.getRandom(); BlockPos blockpos = this.taskOwner.blockPosition(); for(int i = 0; i < 10; ++i) { BlockPos blockpos1 = blockpos.offset(random.nextInt(12) - 6, random.nextInt(4) - 2, random.nextInt(12) - 6); if (isGrazeable() && this.taskOwner.getWalkTargetValue(blockpos1) < 0.0F) { return blockpos1; } } return null; } public boolean isGrazeable() { return (this.entityWorld.getBlockState(this.testpos).is(ModTags.ModBlockTags.GRAZEABLE_BLOCKS) || this.entityWorld.getBlockState(this.testpos.below()).getBlock() == Blocks.GRASS_BLOCK); } }
4,491
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
SmartMateGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/SmartMateGoal.java
package untamedwilds.entity.ai; import net.minecraft.world.entity.ExperienceOrb; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.Level; import untamedwilds.config.ConfigGamerules; import untamedwilds.entity.ComplexMob; import untamedwilds.entity.INestingMob; import java.util.EnumSet; import java.util.List; public class SmartMateGoal extends Goal { private final ComplexMob taskOwner; private final Level world; private final int executionChance; private final Class<? extends ComplexMob> mateClass; private ComplexMob targetMate; private int spawnBabyDelay; private final double moveSpeed; public SmartMateGoal(ComplexMob entityIn, double speedIn) { this(entityIn, speedIn, 120, entityIn.getClass()); } private SmartMateGoal(ComplexMob entityIn, double speedIn, int chance, Class<? extends ComplexMob> mateClass) { this.taskOwner = entityIn; this.world = entityIn.level; this.mateClass = mateClass; this.executionChance = chance; this.moveSpeed = speedIn; this.setFlags(EnumSet.of(Flag.MOVE, Flag.LOOK)); } @Override public boolean canUse() { if (!this.taskOwner.isInLove() || this.taskOwner.getAge() != 0 || this.taskOwner.getRandom().nextInt(this.executionChance) != 0) { return false; } this.targetMate = this.getNearbyMate(); return this.targetMate != null; } @Override public boolean canContinueToUse() { return this.targetMate.isAlive() && this.taskOwner.getAge() == 0 && this.spawnBabyDelay < 200; } @Override public void stop() { this.targetMate = null; this.spawnBabyDelay = 0; } @Override public void tick() { this.taskOwner.getLookControl().setLookAt(this.targetMate, 10.0F, (float) this.taskOwner.getHeadRotSpeed()); this.taskOwner.getNavigation().moveTo(this.targetMate.getX(), this.targetMate.getY(), this.targetMate.getZ(), this.moveSpeed); ++this.spawnBabyDelay; if (this.spawnBabyDelay >= 100 && this.taskOwner.distanceToSqr(this.targetMate) < 9.0D) { this.taskOwner.resetLove(); this.targetMate.resetLove(); if (this.world.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { this.world.addFreshEntity(new ExperienceOrb(this.world, this.taskOwner.getX(), this.taskOwner.getY(), this.taskOwner.getZ(), this.taskOwner.getRandom().nextInt(7) + 1)); } // Positive Growing Age is used as pregnancy counter (handled in ComplexMob) this.taskOwner.setAge(this.taskOwner.getPregnancyTime()); this.targetMate.setAge(this.taskOwner.getPregnancyTime()); if (this.taskOwner instanceof INestingMob nestingMob && nestingMob.isEggLayer()) { if (!this.taskOwner.isMale() || !ConfigGamerules.genderedBreeding.get()) ((INestingMob)this.taskOwner).setEggStatus(true); else ((INestingMob)this.targetMate).setEggStatus(true); } else if (ConfigGamerules.easyBreeding.get()) { if (!this.taskOwner.isMale() || !ConfigGamerules.genderedBreeding.get()) this.taskOwner.breed(); else this.targetMate.breed(); } } } private ComplexMob getNearbyMate() { List<? extends ComplexMob> list = this.world.getEntitiesOfClass(mateClass, this.taskOwner.getBoundingBox().inflate(8.0D)); list.remove(this.taskOwner); double d0 = Double.MAX_VALUE; ComplexMob entityanimal = null; for (ComplexMob potentialMates : list) { if (canMateWith(this.taskOwner, potentialMates) && this.taskOwner.distanceToSqr(potentialMates) < d0) { entityanimal = potentialMates; d0 = this.taskOwner.distanceToSqr(potentialMates); } } return entityanimal; } private boolean canMateWith(ComplexMob father, ComplexMob mother) { if ((ConfigGamerules.genderedBreeding.get() && father.getGender() == mother.getGender()) || father.getVariant() != mother.getVariant()) { return false; } else if (father instanceof INestingMob nesting && (nesting.wantsToLayEggs() || ((INestingMob)mother).wantsToLayEggs())) { return false; } return ConfigGamerules.playerBreeding.get() || (father.wantsToBreed() && mother.wantsToBreed()); } }
4,602
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
MeleeAttackCharger.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/MeleeAttackCharger.java
package untamedwilds.entity.ai; import com.mojang.math.Vector3d; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.targeting.TargetingConditions; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import untamedwilds.entity.ComplexMobTerrestrial; import untamedwilds.entity.mammal.EntityBison; import untamedwilds.entity.mammal.EntityRhino; import untamedwilds.util.EntityUtils; import java.util.EnumSet; import java.util.List; public class MeleeAttackCharger extends Goal { private final int executionChance; private final float speed; private final ComplexMobTerrestrial taskOwner; private double chargeX; private double chargeY; private double chargeZ; private int charge; public MeleeAttackCharger(ComplexMobTerrestrial entityIn, float speedIn, int chance) { this.taskOwner = entityIn; this.speed = speedIn; this.executionChance = chance; this.charge = 0; this.setFlags(EnumSet.of(Flag.TARGET, Flag.MOVE, Flag.LOOK)); } public boolean canUse() { LivingEntity chargeTarget = this.taskOwner.getTarget(); if (this.taskOwner.isBaby() || chargeTarget == null || !this.taskOwner.isOnGround() || this.taskOwner.getRandom().nextInt(this.executionChance) != 0) { return false; } else { double distance = this.taskOwner.distanceTo(chargeTarget); if (distance < 2 || distance > 24 || !this.taskOwner.isOnGround()) { return false; } else { Vec3 chargePos = EntityUtils.getOvershootPath(taskOwner, chargeTarget, 10); boolean canSeeTargetFromDest = taskOwner.getSensing().hasLineOfSight(chargeTarget); if (canSeeTargetFromDest) { chargeX = chargePos.x; chargeY = chargePos.y; chargeZ = chargePos.z; return true; } return false; } } } public void start() { this.charge = 50; if (this.taskOwner instanceof EntityBison) this.taskOwner.setAnimation(EntityBison.ATTACK_THREATEN); if (this.taskOwner instanceof EntityRhino) this.taskOwner.setAnimation(EntityRhino.ATTACK_THREATEN); } public boolean canContinueToUse() { return charge > 0 || !this.taskOwner.getNavigation().isDone(); } public void tick() { this.taskOwner.getLookControl().setLookAt(chargeX, chargeY - 1, chargeZ); if (charge > 0) { if (--charge == 0) { this.taskOwner.getNavigation().moveTo(chargeX, chargeY, chargeZ, this.speed * 1.2F); } else { this.taskOwner.setSprinting(true); } } else { // AABB checking AABB offset_box = this.taskOwner.getBoundingBox().move(Math.cos(Math.toRadians(this.taskOwner.getYRot() + 90)) * 1.2, 0, Math.sin(Math.toRadians(this.taskOwner.getYRot() + 90)) * 1.2); //AxisAlignedBB offset_box = this.taskOwner.getBoundingBox().offset(Math.cos(this.taskOwner.getYRot() * ((float)Math.PI / 180F)), 0, Math.sin(this.taskOwner.getYRot() * ((float)Math.PI / 180F))); /*for (int i = 0; i < 4; i++) { ((ServerWorld)this.taskOwner.world).spawnParticle(ParticleTypes.SOUL_FIRE_FLAME, offset_box.minX, offset_box.minY, offset_box.minZ, 1, 0, 0, 0, 0.05D); ((ServerWorld)this.taskOwner.world).spawnParticle(ParticleTypes.SOUL_FIRE_FLAME, offset_box.maxX, offset_box.maxY, offset_box.maxZ, 1, 0, 0, 0, 0.05D); }*/ List<LivingEntity> entitiesHit = this.taskOwner.getLevel().getNearbyEntities(LivingEntity.class, TargetingConditions.forCombat(), this.taskOwner, offset_box); for (LivingEntity entityHit : entitiesHit) { if (!(entityHit instanceof EntityRhino) && !entityHit.equals(this.taskOwner) && this.taskOwner.hasLineOfSight(entityHit)) { this.taskOwner.doHurtTarget(entityHit); } } } } public void stop() { this.charge = 0; this.taskOwner.setSprinting(false); } }
4,280
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
SmartMeleeAttackGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/SmartMeleeAttackGoal.java
package untamedwilds.entity.ai; import com.github.alexthe666.citadel.animation.IAnimatedEntity; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.util.DefaultRandomPos; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.pathfinder.Node; import net.minecraft.world.level.pathfinder.Path; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import untamedwilds.entity.ComplexMobTerrestrial; import untamedwilds.util.EntityUtils; import java.util.EnumSet; import java.util.Objects; import java.util.Optional; import java.util.Random; public class SmartMeleeAttackGoal extends Goal { protected final PathfinderMob attacker; protected int attackTick; private final double speedTowardsTarget; private final boolean longMemory; private Path path; private int delayCounter; private double targetX; private double targetY; private double targetZ; private final float extraReach; private long field_220720_k; private int failedPathFindingPenalty = 0; private final boolean canPenalize = false; private final boolean doSkirmish; private final boolean isJumper; public SmartMeleeAttackGoal(PathfinderMob entityIn, double speedIn, boolean useLongMemory) { this(entityIn, speedIn, useLongMemory, 0, false, false); } public SmartMeleeAttackGoal(PathfinderMob entityIn, double speedIn, boolean useLongMemory, float reach) { this(entityIn, speedIn, useLongMemory, reach, false, false); } public SmartMeleeAttackGoal(PathfinderMob entityIn, double speedIn, boolean useLongMemory, float reach, boolean doSkirmish, boolean isJumper) { this.attacker = entityIn; this.speedTowardsTarget = speedIn; this.longMemory = useLongMemory; this.extraReach = reach; this.doSkirmish = doSkirmish; this.isJumper = isJumper; this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK)); } @Override public boolean canUse() { if (this.attacker.isBaby() || (this.doSkirmish && !EntityUtils.hasFullHealth(this.attacker)) || (this.attacker instanceof ComplexMobTerrestrial complex && complex.forceSleep > 0)) { return false; } long i = this.attacker.level.getGameTime(); if (i - this.field_220720_k < 20L) { return false; } else { this.field_220720_k = i; LivingEntity livingentity = this.attacker.getTarget(); if (livingentity == null) { return false; } else if (!livingentity.isAlive()) { return false; } else { if (canPenalize) { if (--this.delayCounter <= 0) { this.path = this.attacker.getNavigation().createPath(livingentity, 0); this.delayCounter = 4 + this.attacker.getRandom().nextInt(7); return this.path != null; } else { return true; } } this.path = this.attacker.getNavigation().createPath(livingentity, 0); return this.path != null; } } } @Override public boolean canContinueToUse() { // TODO: DEBUG: Skirmish option, where a mob low on health will retreat if targeted, disabled if (false && this.doSkirmish && !EntityUtils.hasFullHealth(this.attacker)) { if (this.attacker.getTarget() instanceof PathfinderMob targetEntity) { if (Objects.equals(targetEntity.getTarget(), this.attacker)) { Vec3 vec3d = DefaultRandomPos.getPosAway(targetEntity, 12, 4, new Vec3(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ())); if (vec3d != null) { this.attacker.setTarget(null); this.attacker.getNavigation().moveTo(vec3d.x, vec3d.y, vec3d.z, this.speedTowardsTarget); return false; } } } } LivingEntity livingentity = this.attacker.getTarget(); if (livingentity == null || (this.attacker.getAirSupply() < 40 && !this.attacker.canBreatheUnderwater()) || !livingentity.isAlive()) { return false; } else if (!this.longMemory) { return !this.attacker.getNavigation().isDone(); } else if (!this.attacker.isWithinRestriction(livingentity.blockPosition())) { return false; } else { return !(livingentity instanceof Player) || !livingentity.isSpectator() && !((Player)livingentity).isCreative(); } } public void start() { this.attacker.getNavigation().moveTo(this.path, this.speedTowardsTarget); this.attacker.setAggressive(true); this.delayCounter = 0; } public void stop() { /*LivingEntity livingentity = this.attacker.getTarget(); if (!TargetingConditions.forCombat().test(this.attacker, livingentity)) { this.attacker.setTarget(null); }*/ this.attacker.setTarget(null); // <- Edited this.attacker.setAggressive(false); this.attacker.getNavigation().stop(); } public void tick() { LivingEntity livingentity = this.attacker.getTarget(); this.attacker.getLookControl().setLookAt(Vec3.atCenterOf(livingentity.blockPosition())); //this.attacker.getLookControl().setLookAt(livingentity, 30.0F, 30.0F); double d0 = this.attacker.distanceToSqr(livingentity.getX(), livingentity.getBoundingBox().minY, livingentity.getZ()); --this.delayCounter; // This piece of code fixes mobs in water being unable to chase upwards if (this.attacker.isInWater() && this.attacker.tickCount % 12 == 0) { if ((livingentity.getBoundingBox().minY - 2) > this.attacker.getY()) { this.attacker.getJumpControl().jump(); } } if ((this.longMemory || this.attacker.getSensing().hasLineOfSight(livingentity)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || livingentity.distanceToSqr(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRandom().nextFloat() < 0.05F)) { this.targetX = livingentity.getX(); this.targetY = livingentity.getBoundingBox().minY; this.targetZ = livingentity.getZ(); this.delayCounter = 4 + this.attacker.getRandom().nextInt(7); if (this.canPenalize) { this.delayCounter += failedPathFindingPenalty; if (this.attacker.getNavigation().getPath() != null) { Node finalPathPoint = this.attacker.getNavigation().getPath().getEndNode(); if (finalPathPoint != null && livingentity.distanceToSqr(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z) < 1) failedPathFindingPenalty = 0; else failedPathFindingPenalty += 10; } else { failedPathFindingPenalty += 10; } } if (d0 > 1024.0D) { this.delayCounter += 10; } else if (d0 > 256.0D) { this.delayCounter += 5; } if (!this.attacker.getNavigation().moveTo(livingentity, this.speedTowardsTarget)) { this.delayCounter += 15; } } BlockPos forwardNearPos = EntityUtils.getRelativeBlockPos(this.attacker, 1.2F, 0); if (this.isJumper && this.attacker.isOnGround() && this.attacker.getLevel().getBlockState(forwardNearPos.below()).isAir() && this.attacker.getLevel().getBlockState(forwardNearPos.below(2)).isAir() && this.attacker.getSensing().hasLineOfSight(livingentity)) { BlockPos forwardFarPos = EntityUtils.getRelativeBlockPos(this.attacker, 5F, 0); if (new Vec3(forwardFarPos.getX(), forwardFarPos.getY(), forwardFarPos.getZ()).distanceTo(livingentity.getPosition(0)) < this.attacker.getPosition(0).distanceTo(livingentity.getPosition(0))) { //this.attacker.getEntityWorld().setBlockState(targetpos, Blocks.TORCH.defaultBlockState()); Random rand = this.attacker.getRandom(); for (int i = 0; i < 4; i++) { forwardFarPos.offset(rand.nextInt(2) - 1, rand.nextInt(2) - 1, rand.nextInt(2) - 1); if (this.attacker.getNavigation().isStableDestination(forwardFarPos)) { Optional<Vec3> jump_vec = this.calculateOptimalJumpVector(this.attacker, Vec3.atCenterOf(forwardFarPos)); if (jump_vec.isPresent()) { double d1 = jump_vec.get().length(); double d2 = 1 + d1 + (this.attacker.hasEffect(MobEffects.JUMP) ? (double)(0.1F * (float)(this.attacker.getEffect(MobEffects.JUMP).getAmplifier() + 1)) : 0.0D); this.attacker.setDeltaMovement(jump_vec.get().x * d2 / d1, jump_vec.get().y, jump_vec.get().z * d2 / d1); this.attacker.getNavigation().stop(); break; } } } } } this.attackTick = Math.max(this.attackTick - 1, 0); this.checkAndPerformAttack(livingentity, d0); } protected void checkAndPerformAttack(LivingEntity enemy, double distToEnemySqr) { double d0 = this.getAttackReachSqr(enemy); if (this.attacker.hasLineOfSight(enemy) && distToEnemySqr <= d0 && (this.attackTick <= 0 || (this.attackTick <= 10 && this.attacker instanceof IAnimatedEntity animated && animated.getAnimation() == IAnimatedEntity.NO_ANIMATION))) { this.attackTick = 20; this.attacker.doHurtTarget(enemy); } } protected double getAttackReachSqr(LivingEntity attackTarget) { return (this.attacker.getBbWidth() * 2.0F * this.attacker.getBbWidth() * 2.0F + attackTarget.getBbWidth() + this.extraReach); } // Start of the code gore private Optional<Vec3> calculateOptimalJumpVector(PathfinderMob entityIn, Vec3 p_147658_) { Optional<Vec3> optional = Optional.empty(); for(int i = 20; i < 55; i += 5) { //for(int i = 65; i < 85; i += 5) { Optional<Vec3> optional1 = this.calculateJumpVectorForAngle(entityIn, p_147658_, i); if (optional.isEmpty() || optional1.isPresent() && optional1.get().lengthSqr() < optional.get().lengthSqr()) { optional = optional1; } } return optional; } private Optional<Vec3> calculateJumpVectorForAngle(PathfinderMob entityIn, Vec3 p_147661_, int angleIn) { Vec3 vec3 = entityIn.position(); Vec3 vec31 = (new Vec3(p_147661_.x - vec3.x, 0.0D, p_147661_.z - vec3.z)).normalize().scale(0.5D); p_147661_ = p_147661_.subtract(vec31); Vec3 vec32 = p_147661_.subtract(vec3); float f = (float)angleIn * (float)Math.PI / 180.0F; double d0 = Math.atan2(vec32.z, vec32.x); double d1 = vec32.subtract(0.0D, vec32.y, 0.0D).lengthSqr(); double d2 = Math.sqrt(d1); double d3 = vec32.y; double d4 = Math.sin(2.0F * f); double d6 = Math.pow(Math.cos(f), 2.0D); double d7 = Math.sin(f); double d8 = Math.cos(f); double d9 = Math.sin(d0); double d10 = Math.cos(d0); double d11 = d1 * 0.08D / (d2 * d4 - 2.0D * d3 * d6); if (d11 < 0.0D) { return Optional.empty(); } else { double d12 = Math.sqrt(d11); /*if (d12 > (double)this.maxJumpVelocity) { return Optional.empty(); } else {*/ double d13 = d12 * d8; double d14 = d12 * d7; int i = Mth.ceil(d2 / d13) * 2; double d15 = 0.0D; Vec3 vec33 = null; for(int j = 0; j < i - 1; ++j) { d15 += d2 / (double)i; double d16 = d7 / d8 * d15 - Math.pow(d15, 2.0D) * 0.08D / (2.0D * d11 * Math.pow(d8, 2.0D)); double d17 = d15 * d10; double d18 = d15 * d9; Vec3 vec34 = new Vec3(vec3.x + d17, vec3.y + d16, vec3.z + d18); if (vec33 != null && !this.isClearTransition(entityIn, vec33, vec34)) { return Optional.empty(); } vec33 = vec34; } return Optional.of((new Vec3(d13 * d10, d14, d13 * d9)).scale(0.95F)); //} } } private boolean isClearTransition(Mob p_147664_, Vec3 p_147665_, Vec3 p_147666_) { EntityDimensions entitydimensions = p_147664_.getDimensions(Pose.LONG_JUMPING); Vec3 vec3 = p_147666_.subtract(p_147665_); double d0 = Math.min(entitydimensions.width, entitydimensions.height); int i = Mth.ceil(vec3.length() / d0); Vec3 vec31 = vec3.normalize(); Vec3 vec32 = p_147665_; for(int j = 0; j < i; ++j) { vec32 = j == i - 1 ? p_147666_ : vec32.add(vec31.scale(d0 * (double)0.9F)); AABB aabb = entitydimensions.makeBoundingBox(vec32); if (!p_147664_.level.noCollision(p_147664_, aabb)) { return false; } } return true; } }
13,751
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z
SmartWanderGoal.java
/FileExtraction/Java_unseen/RayTrace082_untamedwilds/src/main/java/untamedwilds/entity/ai/SmartWanderGoal.java
package untamedwilds.entity.ai; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.util.DefaultRandomPos; import net.minecraft.world.phys.Vec3; import untamedwilds.entity.ComplexMobTerrestrial; import untamedwilds.entity.IPackEntity; import java.util.EnumSet; public class SmartWanderGoal extends Goal { public final ComplexMobTerrestrial creature; protected double x; protected double y; protected double z; private final int runChance; private final int executionChance; private final boolean avoidWater; private final double speed; public SmartWanderGoal(ComplexMobTerrestrial entityIn, double speedIn) { this(entityIn, speedIn, 120, 0,false); } public SmartWanderGoal(ComplexMobTerrestrial entityIn, double speedIn, boolean avoidWater) { this(entityIn, speedIn, 120, 0, avoidWater); } public SmartWanderGoal(ComplexMobTerrestrial entityIn, double speedIn, int runChance, boolean avoidWater) { this(entityIn, speedIn, 120, runChance, avoidWater); } public SmartWanderGoal(ComplexMobTerrestrial entityIn, double speedIn, int chance, int runChance, boolean avoidWater) { this.creature = entityIn; this.speed = speedIn; this.executionChance = this.creature.isActive() ? chance : chance * 5; this.runChance = runChance; this.avoidWater = avoidWater; this.setFlags(EnumSet.of(Goal.Flag.MOVE)); } @Override public boolean canUse() { if (!this.creature.canMove() || !this.creature.getNavigation().isDone() || this.creature.getCommandInt() != 0 || this.creature.getRandom().nextInt(this.executionChance) != 0) { return false; } Vec3 vec3d = this.getPosition(); if (vec3d == null) { return false; } else { this.x = vec3d.x; this.y = vec3d.y; this.z = vec3d.z; return true; } } private Vec3 getPosition() { // If this AI goal runs on an IPackEntity, use Herd-specific behavior if (this.creature instanceof IPackEntity && this.creature.herd != null && this.creature.herd.getLeader() != this.creature) { Vec3 vec3d = DefaultRandomPos.getPos(this.creature.herd.getLeader(), 7, 3); return vec3d == null ? DefaultRandomPos.getPos(this.creature.herd.getLeader(), 5, 2) : vec3d; } if (this.avoidWater) { Vec3 vec3d = DefaultRandomPos.getPos(this.creature, 15, 7); return vec3d == null ? DefaultRandomPos.getPos(this.creature, 10, 4) : vec3d; } else { return DefaultRandomPos.getPos(this.creature, 10, 4); } } @Override public boolean canContinueToUse() { return !this.creature.getNavigation().isDone(); } @Override public void start() { this.creature.getNavigation().moveTo(this.x, this.y, this.z, this.speed * (this.creature.getRandom().nextInt(100) < this.runChance ? 2f : 1f)); } }
3,049
Java
.java
RayTrace082/untamedwilds
13
11
79
2020-07-25T21:16:24Z
2024-05-06T16:27:45Z