diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java index 818cddfc5..a905070c8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java @@ -30,7 +30,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, protected OrientedData hand; AllBlockPartials currentHand; - float progress = Float.NaN; + float progress; private boolean newHand = false; public DeployerInstance(InstancedTileRenderer dispatcher, KineticTileEntity tile) { @@ -50,9 +50,9 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, updateHandPose(); relight(pos, pole); + progress = getProgress(AnimationTickHolder.getPartialTicks()); updateRotation(pole, hand, yRot, zRot, zRotPole); - - beginFrame(); + updatePosition(); } @Override @@ -70,19 +70,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, progress = newProgress; newHand = false; - float handLength = currentHand == AllBlockPartials.DEPLOYER_HAND_POINTING ? 0 - : currentHand == AllBlockPartials.DEPLOYER_HAND_HOLDING ? 4 / 16f : 3 / 16f; - float distance = Math.min(MathHelper.clamp(progress, 0, 1) * (tile.reach + handLength), 21 / 16f); - Vec3i facingVec = facing.getDirectionVec(); - BlockPos blockPos = getInstancePosition(); - - float x = blockPos.getX() + ((float) facingVec.getX()) * distance; - float y = blockPos.getY() + ((float) facingVec.getY()) * distance; - float z = blockPos.getZ() + ((float) facingVec.getZ()) * distance; - - pole.setPosition(x, y, z); - hand.setPosition(x, y, z); - + updatePosition(); } @Override @@ -110,6 +98,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, relight(pos, hand); updateRotation(pole, hand, yRot, zRot, zRotPole); + updatePosition(); return true; } @@ -122,6 +111,21 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, return 0; } + private void updatePosition() { + float handLength = currentHand == AllBlockPartials.DEPLOYER_HAND_POINTING ? 0 + : currentHand == AllBlockPartials.DEPLOYER_HAND_HOLDING ? 4 / 16f : 3 / 16f; + float distance = Math.min(MathHelper.clamp(progress, 0, 1) * (tile.reach + handLength), 21 / 16f); + Vec3i facingVec = facing.getDirectionVec(); + BlockPos blockPos = getInstancePosition(); + + float x = blockPos.getX() + ((float) facingVec.getX()) * distance; + float y = blockPos.getY() + ((float) facingVec.getY()) * distance; + float z = blockPos.getZ() + ((float) facingVec.getZ()) * distance; + + pole.setPosition(x, y, z); + hand.setPosition(x, y, z); + } + static void updateRotation(OrientedData pole, OrientedData hand, float yRot, float zRot, float zRotPole) { Quaternion q = Direction.SOUTH.getUnitVector().getDegreesQuaternion(zRot);