From f44618b547a2ad941d77fe598f0b41538926d36b Mon Sep 17 00:00:00 2001 From: roadhog360 Date: Tue, 15 Oct 2024 00:24:13 -0500 Subject: [PATCH] Fix squid sound , potential fix for #529 --- .../core/handlers/ServerEventHandler.java | 4 +- .../etfuturum/entities/EntityRabbit.java | 45 +++++++++++-------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java b/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java index 713fbe27..166d0cd9 100644 --- a/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java +++ b/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java @@ -1694,9 +1694,7 @@ public void livingHurtEvent(LivingHurtEvent event) { serverWorld.func_147487_a("largesmoke", cx, cy, cz, 5, 0.0, 0.0, 0.0, 0.08); if (ConfigMixins.newMobSounds) { float pitch = (r.nextFloat() - r.nextFloat()) * 0.2F + (target.isChild() ? 1.5F : 1.0F); - if(ConfigMixins.newMobSounds) { - w.playSoundAtEntity(target, Reference.MCAssetVer + ":entity.squid.squirt", 0.4F, pitch); - } + w.playSoundAtEntity(target, Reference.MCAssetVer + ":entity.squid.squirt", 0.4F, pitch); } if (target.isInWater()) { PotionEffect activeEff = target.getActivePotionEffect(Potion.blindness); diff --git a/src/main/java/ganymedes01/etfuturum/entities/EntityRabbit.java b/src/main/java/ganymedes01/etfuturum/entities/EntityRabbit.java index 5bd9966f..ad08bccd 100644 --- a/src/main/java/ganymedes01/etfuturum/entities/EntityRabbit.java +++ b/src/main/java/ganymedes01/etfuturum/entities/EntityRabbit.java @@ -61,13 +61,13 @@ public EntityRabbit(World world) { } @Override - public RabbitMoveHelper getMoveHelper() { - return (RabbitMoveHelper) super.getMoveHelper(); + public EntityMoveHelper getMoveHelper() { + return super.getMoveHelper(); } @Override - public RabbitJumpHelper getJumpHelper() { - return (RabbitJumpHelper) super.getJumpHelper(); + public EntityJumpHelper getJumpHelper() { + return super.getJumpHelper(); } public void setMoveType(EntityRabbit.EnumMoveType type) { @@ -80,7 +80,7 @@ public float getJumpCompletion(float p_175521_1_) { public void setMovementSpeed(double newSpeed) { getNavigator().setSpeed(newSpeed); - getMoveHelper().setMoveTo(getMoveHelper().getX(), getMoveHelper().getY(), getMoveHelper().getZ(), newSpeed); + getMoveHelper().setMoveTo(getMoveHelper().posX, getMoveHelper().posY, getMoveHelper().posZ, newSpeed); } public void setJumping(boolean jump, EntityRabbit.EnumMoveType moveTypeIn) { @@ -167,21 +167,24 @@ else if (moveType != EntityRabbit.EnumMoveType.ATTACK) checkLandingDelay(); } - EntityRabbit.RabbitJumpHelper rabbitjumphelper = getJumpHelper(); + EntityJumpHelper jumpHelper = getJumpHelper(); - if (!rabbitjumphelper.getIsJumping()) { - if (!getNavigator().noPath() && currentMoveTypeDuration == 0) { - PathEntity pathentity = getNavigator().getPath(); - Vec3 vec3 = Vec3.createVectorHelper(getMoveHelper().getX(), getMoveHelper().getY(), getMoveHelper().getZ()); + if (jumpHelper instanceof RabbitJumpHelper rabbitJumpHelper) { + if (!rabbitJumpHelper.getIsJumping()) { + if (!getNavigator().noPath() && currentMoveTypeDuration == 0) { + PathEntity pathentity = getNavigator().getPath(); + Vec3 vec3 = Vec3.createVectorHelper(getMoveHelper().posX, getMoveHelper().posY, getMoveHelper().posZ); - if (pathentity != null && pathentity.getCurrentPathIndex() < pathentity.getCurrentPathLength()) - vec3 = pathentity.getPosition(this); + if (pathentity != null && pathentity.getCurrentPathIndex() < pathentity.getCurrentPathLength()) + vec3 = pathentity.getPosition(this); - calculateRotationYaw(vec3.xCoord, vec3.zCoord); - doMovementAction(moveType); - } - } else if (!rabbitjumphelper.canJump()) - enableJumpControl(); + calculateRotationYaw(vec3.xCoord, vec3.zCoord); + doMovementAction(moveType); + } + } else if (!rabbitJumpHelper.canJump()) { + enableJumpControl(); + } + } } wasOnGround = onGround; @@ -192,11 +195,15 @@ private void calculateRotationYaw(double p_175533_1_, double p_175533_3_) { } private void enableJumpControl() { - getJumpHelper().setCanJump(true); + if(getJumpHelper() instanceof RabbitJumpHelper rabbitJumpHelper) { + rabbitJumpHelper.setCanJump(true); + } } private void disableJumpControl() { - getJumpHelper().setCanJump(false); + if(getJumpHelper() instanceof RabbitJumpHelper rabbitJumpHelper) { + rabbitJumpHelper.setCanJump(false); + } } private void updateMoveTypeDuration() {