diff --git a/src/main/java/com/troblecodings/signals/animation/ModelTranslation.java b/src/main/java/com/troblecodings/signals/animation/ModelTranslation.java index a25549cf9..cc622241d 100644 --- a/src/main/java/com/troblecodings/signals/animation/ModelTranslation.java +++ b/src/main/java/com/troblecodings/signals/animation/ModelTranslation.java @@ -8,30 +8,26 @@ public class ModelTranslation { - private VectorWrapper firstTranslation; + private VectorWrapper pivotTranslation; private Quaternion quaternion = new Quaternion(0, 0, 0, 0); - private VectorWrapper lastTranslation; private SignalAnimation animation; private VectorWrapper modelTranslation = VectorWrapper.ZERO; private boolean renderModel = false; - public ModelTranslation(final VectorWrapper firstTranslation, final Quaternion quaternion, - final VectorWrapper lastTranslation) { - this.firstTranslation = firstTranslation; + public ModelTranslation(final VectorWrapper firstTranslation, final Quaternion quaternion) { + this.pivotTranslation = firstTranslation; this.quaternion = quaternion; - this.lastTranslation = lastTranslation; } public void translate(final RenderAnimationInfo info) { - info.stack.translate(firstTranslation.getX(), firstTranslation.getY(), - firstTranslation.getZ()); - info.stack.mulPose(quaternion); - info.stack.translate(lastTranslation.getX(), lastTranslation.getY(), - lastTranslation.getZ()); + if (!modelTranslation.equals(VectorWrapper.ZERO)) { info.stack.translate(modelTranslation.getX(), modelTranslation.getY(), - modelTranslation.getZ()); + modelTranslation.getZ()); // Modell verschieben } + info.stack.mulPose(quaternion); + info.stack.translate(pivotTranslation.getX(), pivotTranslation.getY(), + pivotTranslation.getZ()); // Pivot Punkt } public Quaternion getQuaternion() { @@ -48,9 +44,8 @@ public ModelTranslation setRenderModel(final boolean renderModel) { } public void setUpNewTranslation(final ModelTranslation other) { - this.firstTranslation = other.firstTranslation; + this.pivotTranslation = other.pivotTranslation; this.quaternion = other.quaternion; - this.lastTranslation = other.lastTranslation; } public void setModelTranslation(final VectorWrapper translation) { @@ -75,7 +70,7 @@ public SignalAnimation getAssigendAnimation() { @Override public int hashCode() { - return Objects.hash(firstTranslation, lastTranslation, quaternion, renderModel); + return Objects.hash(pivotTranslation, quaternion, renderModel); } @Override @@ -87,8 +82,7 @@ public boolean equals(final Object obj) { if (getClass() != obj.getClass()) return false; final ModelTranslation other = (ModelTranslation) obj; - return Objects.equals(firstTranslation, other.firstTranslation) - && Objects.equals(lastTranslation, other.lastTranslation) + return Objects.equals(pivotTranslation, other.pivotTranslation) && Objects.equals(quaternion, other.quaternion) && renderModel == other.renderModel; } diff --git a/src/main/java/com/troblecodings/signals/animation/SignalAnimationHandler.java b/src/main/java/com/troblecodings/signals/animation/SignalAnimationHandler.java index 688108d32..0f34bafb7 100644 --- a/src/main/java/com/troblecodings/signals/animation/SignalAnimationHandler.java +++ b/src/main/java/com/troblecodings/signals/animation/SignalAnimationHandler.java @@ -40,8 +40,8 @@ public void render(final RenderAnimationInfo info) { final BlockState state = tile.getBlockState(); final SignalAngel angle = state.getValue(Signal.ANGEL); final ModelBlockRenderer renderer = info.dispatcher.getModelRenderer(); - final VertexConsumer vertex = info.source - .getBuffer(ItemBlockRenderTypes.getRenderType(state, false)); + final VertexConsumer vertex = + info.source.getBuffer(ItemBlockRenderTypes.getRenderType(state, false)); final IModelData data = tile.getModelData(); animationPerModel.forEach((model, entry) -> { @@ -57,8 +57,9 @@ public void render(final RenderAnimationInfo info) { info.overlayTexture, data); info.stack.popPose(); - if (translation.isAnimationAssigned()) + if (translation.isAnimationAssigned()) { updateAnimation(translation); + } }); } @@ -125,8 +126,8 @@ public void updateAnimationListFromBlock() { map.forEach((entry, animations) -> { final BakedModel model = SignalCustomModel.getModelFromLocation( new ResourceLocation(OpenSignalsMain.MODID, entry.getKey())); - final ModelTranslation translation = new ModelTranslation(VectorWrapper.ZERO, - new Quaternion(0, 0, 0, 0), VectorWrapper.ZERO); + final ModelTranslation translation = + new ModelTranslation(VectorWrapper.ZERO, new Quaternion(0, 0, 0, 0)); translation.setModelTranslation(entry.getValue()); animationPerModel.put(model, Maps.immutableEntry(translation, animations)); }); diff --git a/src/main/java/com/troblecodings/signals/animation/SignalAnimationRotation.java b/src/main/java/com/troblecodings/signals/animation/SignalAnimationRotation.java index 6e22761f7..0162aa2a1 100644 --- a/src/main/java/com/troblecodings/signals/animation/SignalAnimationRotation.java +++ b/src/main/java/com/troblecodings/signals/animation/SignalAnimationRotation.java @@ -65,17 +65,18 @@ public void setUpAnimationValues(final ModelTranslation currentTranslation) { @Override public ModelTranslation getFinalModelTranslation() { - return new ModelTranslation(pivot, axis.getForAxis(-rotation * 0.005f * animationSpeed), - pivot); + return new ModelTranslation(pivot, axis.getForAxis(-rotation * 0.005f * animationSpeed)); } @Override public ModelTranslation getModelTranslation() { - return new ModelTranslation(pivot, calc.getQuaternion(), pivot); + return new ModelTranslation(pivot, calc.getQuaternion()); } @Override public boolean isFinished() { + if (calc == null) + return true; return calc.isAnimationFinished(); } diff --git a/src/main/resources/assets/opensignals/animations/semaphoresignal.json b/src/main/resources/assets/opensignals/animations/semaphoresignal.json index 0936627b4..2e30c4aa7 100644 --- a/src/main/resources/assets/opensignals/animations/semaphoresignal.json +++ b/src/main/resources/assets/opensignals/animations/semaphoresignal.json @@ -1,24 +1,26 @@ { "animations": { "semaphore_signals/sema_main_wing1": { - "translationX": 5, + "translationX": 0.15, + "translationY": 6.95, + "translationZ": -0.5, "animationConfigs": [ { "predicate": "config(WING1.FALSE)", "mode": "ROTATION", "rotationAxis": "Z", "rotation": 0, - "pivotX": 0, - "pivotY": 0, + "pivotX": -0.65, + "pivotY": -4.45, "pivotZ": 0 }, { "predicate": "config(WING1.TRUE)", "mode": "ROTATION", "rotationAxis": "Z", - "rotation": 100, - "pivotX": 0, - "pivotY": 0, + "rotation": 155, + "pivotX": -0.65, + "pivotY": -4.45, "pivotZ": 0 } ]