From b91a9bbf285d0cb75f39399228b989165de267a2 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Mon, 8 Jun 2020 21:39:03 +0200 Subject: [PATCH] Kinetic loops - Fixed cases of self-powering loops caused by blocks rotated using the wrench, addresses #319 - Fixed Extendo Grip animation for left-handed players --- .../content/contraptions/base/KineticTileEntity.java | 5 ++++- .../components/crafter/MechanicalCrafterBlock.java | 6 +++--- .../curiosities/tools/ExtendoGripRenderHandler.java | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java index 9e22ee09d..023927120 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java @@ -353,6 +353,10 @@ public abstract class KineticTileEntity extends SmartTileEntity TileEntity tileEntityIn = world.getTileEntity(pos); boolean isKinetic = tileEntityIn instanceof KineticTileEntity; + if (tileEntityIn == null) + return; + if (tileEntityIn.getBlockState() == state) + return; if (!isKinetic) { world.setBlockState(pos, state, 3); return; @@ -365,7 +369,6 @@ public abstract class KineticTileEntity extends SmartTileEntity tileEntity.detachKinetics(); tileEntity.removeSource(); world.setBlockState(pos, state, 3); - tileEntity.attachKinetics(); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java index 35b1c9e0e..4afe0c11b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterBlock.java @@ -4,6 +4,7 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock; +import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.components.crafter.ConnectedInputHandler.ConnectedInput; import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase; import com.simibubi.create.foundation.block.ITE; @@ -154,9 +155,8 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { if (context.getFace() == state.get(HORIZONTAL_FACING)) { - context.getWorld() - .setBlockState(context.getPos(), state.cycle(POINTING)); - withTileEntityDo(context.getWorld(), context.getPos(), TileEntity::markDirty); + if (!context.getWorld().isRemote) + KineticTileEntity.switchToBlockState(context.getWorld(), context.getPos(), state.cycle(POINTING)); return ActionResultType.SUCCESS; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java index 7c4b6b348..895595e12 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java @@ -94,7 +94,7 @@ public class ExtendoGripRenderHandler { .rotateY(flip * -135.0F); ms.translate(flip * 5.6F, 0.0F, 0.0F); msr.rotateY(flip * 40.0F); - ms.translate(0.05f, -0.3f, -0.3f); + ms.translate(flip * 0.05f, -0.3f, -0.3f); PlayerRenderer playerrenderer = (PlayerRenderer) mc.getRenderManager() .getRenderer(player); @@ -115,14 +115,14 @@ public class ExtendoGripRenderHandler { if (!notInOffhand) { ForgeHooksClient.handleCameraTransforms(ms, mc.getItemRenderer() - .getItemModelWithOverrides(offhandItem, null, null), transform, false); + .getItemModelWithOverrides(offhandItem, null, null), transform, !rightHand); ms.translate(flip * -.05f, .15f, -1.2f); ms.translate(0, 0, -animation * 2.25f); if (blockItem && mc.getItemRenderer() .getItemModelWithOverrides(heldItem, null, null) .isGui3d()) { - msr.rotateY(45); - ms.translate(0.15f, -0.15f, -.05f); + msr.rotateY(flip * 45); + ms.translate(flip * 0.15f, -0.15f, -.05f); ms.scale(1.25f, 1.25f, 1.25f); }