diff --git a/src/main/java/baguchan/better_with_aquatic/mixin/EntityPlayerMixin.java b/src/main/java/baguchan/better_with_aquatic/mixin/EntityPlayerMixin.java index da51b31..a6d6b56 100644 --- a/src/main/java/baguchan/better_with_aquatic/mixin/EntityPlayerMixin.java +++ b/src/main/java/baguchan/better_with_aquatic/mixin/EntityPlayerMixin.java @@ -63,14 +63,19 @@ public void moveEntityWithHeading(float moveStrafing, float moveForward, Callbac || this.world.getBlockMaterial((int) (this.x), (int) (this.y + 1.0 - 0.1), (int) (this.z)) == Material.water) { this.yd += (d3 - yd) * d4; } - this.moveRelative(moveStrafing, moveForward, 0.025F); + this.xd += (this.getLookAngle().xCoord - xd) * 0.025F; + this.zd += (this.getLookAngle().zCoord - zd) * 0.025F; } } @Inject(method = "onLivingUpdate", at = @At("HEAD")) public void onLivingUpdate(CallbackInfo ci) { - if (this.world.getBlockId((int) (this.x), (int) this.y + 1, (int) (this.z)) != 0 && this.world.getBlockMaterial((int) (this.x), (int) this.y + 1, (int) (this.z)) != Material.water && (!this.isInWater())) { + if (!(this.world.getBlockId((int) (this.x), (int) this.y + 1, (int) (this.z)) != 0 && this.world.getBlockMaterial((int) (this.x), (int) this.y + 1, (int) (this.z)) != Material.water) && this.isVisuallyCrawling()) { + this.setSwimming(false); + } + + if (this.isSwimming() && this.isInWater() && this.moveForward == 0 && this.moveStrafing == 0) { this.setSwimming(false); } this.updateSwimAmount(); diff --git a/src/main/java/baguchan/better_with_aquatic/mixin/NetHandlerMixin.java b/src/main/java/baguchan/better_with_aquatic/mixin/NetHandlerMixin.java index 25f8ae5..fa410bd 100644 --- a/src/main/java/baguchan/better_with_aquatic/mixin/NetHandlerMixin.java +++ b/src/main/java/baguchan/better_with_aquatic/mixin/NetHandlerMixin.java @@ -10,7 +10,7 @@ @Mixin(value = NetHandler.class, remap = false) public class NetHandlerMixin implements ISwimPacket { - public void handleMobEnchant(SwimPacket packet) { + public void handleSwim(SwimPacket packet) { this.handleInvalidPacket(packet); } diff --git a/src/main/java/baguchan/better_with_aquatic/mixin/NetServerHandlerMixin.java b/src/main/java/baguchan/better_with_aquatic/mixin/NetServerHandlerMixin.java index 8ac3fda..0f9be5f 100644 --- a/src/main/java/baguchan/better_with_aquatic/mixin/NetServerHandlerMixin.java +++ b/src/main/java/baguchan/better_with_aquatic/mixin/NetServerHandlerMixin.java @@ -14,7 +14,7 @@ public class NetServerHandlerMixin implements ISwimPacket { private EntityPlayerMP playerEntity; @Override - public void handleMobEnchant(SwimPacket packet) { + public void handleSwim(SwimPacket packet) { if (playerEntity instanceof ISwiming) { ((ISwiming) playerEntity).setSwimming(packet.swim); } diff --git a/src/main/java/baguchan/better_with_aquatic/mixin/client/KeyboardInputMixin.java b/src/main/java/baguchan/better_with_aquatic/mixin/client/KeyboardInputMixin.java index efaa687..d7d8cb6 100644 --- a/src/main/java/baguchan/better_with_aquatic/mixin/client/KeyboardInputMixin.java +++ b/src/main/java/baguchan/better_with_aquatic/mixin/client/KeyboardInputMixin.java @@ -25,8 +25,9 @@ public class KeyboardInputMixin { @Inject(method = "tick", at = @At(value = "TAIL")) public void tick(EntityPlayer entityplayer, CallbackInfo ci) { - if (entityplayer.isInWater()) { + if (entityplayer instanceof ISwiming) { + if (entityplayer.isInWater()) { if (keys[0]) { this.sprintTime = 0; if (this.sprintTime < 9) { diff --git a/src/main/java/baguchan/better_with_aquatic/packet/ISwimPacket.java b/src/main/java/baguchan/better_with_aquatic/packet/ISwimPacket.java index 333fcfd..d2df82a 100644 --- a/src/main/java/baguchan/better_with_aquatic/packet/ISwimPacket.java +++ b/src/main/java/baguchan/better_with_aquatic/packet/ISwimPacket.java @@ -1,5 +1,5 @@ package baguchan.better_with_aquatic.packet; public interface ISwimPacket { - void handleMobEnchant(SwimPacket packet); + void handleSwim(SwimPacket packet); } diff --git a/src/main/java/baguchan/better_with_aquatic/packet/SwimPacket.java b/src/main/java/baguchan/better_with_aquatic/packet/SwimPacket.java index de81657..a7a3363 100644 --- a/src/main/java/baguchan/better_with_aquatic/packet/SwimPacket.java +++ b/src/main/java/baguchan/better_with_aquatic/packet/SwimPacket.java @@ -27,7 +27,7 @@ public void writePacketData(DataOutputStream dataOutputStream) throws IOExceptio @Override public void processPacket(NetHandler netHandler) { - ((ISwimPacket) netHandler).handleMobEnchant(this); + ((ISwimPacket) netHandler).handleSwim(this); } @Override