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
This commit is contained in:
simibubi 2020-06-08 21:39:03 +02:00
parent 20a97c6b39
commit b91a9bbf28
3 changed files with 11 additions and 8 deletions

View file

@ -353,6 +353,10 @@ public abstract class KineticTileEntity extends SmartTileEntity
TileEntity tileEntityIn = world.getTileEntity(pos); TileEntity tileEntityIn = world.getTileEntity(pos);
boolean isKinetic = tileEntityIn instanceof KineticTileEntity; boolean isKinetic = tileEntityIn instanceof KineticTileEntity;
if (tileEntityIn == null)
return;
if (tileEntityIn.getBlockState() == state)
return;
if (!isKinetic) { if (!isKinetic) {
world.setBlockState(pos, state, 3); world.setBlockState(pos, state, 3);
return; return;
@ -365,7 +369,6 @@ public abstract class KineticTileEntity extends SmartTileEntity
tileEntity.detachKinetics(); tileEntity.detachKinetics();
tileEntity.removeSource(); tileEntity.removeSource();
world.setBlockState(pos, state, 3); world.setBlockState(pos, state, 3);
tileEntity.attachKinetics();
} }
@Override @Override

View file

@ -4,6 +4,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.AllTileEntities; import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock; 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.ConnectedInputHandler.ConnectedInput;
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase; import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
@ -154,9 +155,8 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock implements IT
@Override @Override
public ActionResultType onWrenched(BlockState state, ItemUseContext context) { public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
if (context.getFace() == state.get(HORIZONTAL_FACING)) { if (context.getFace() == state.get(HORIZONTAL_FACING)) {
context.getWorld() if (!context.getWorld().isRemote)
.setBlockState(context.getPos(), state.cycle(POINTING)); KineticTileEntity.switchToBlockState(context.getWorld(), context.getPos(), state.cycle(POINTING));
withTileEntityDo(context.getWorld(), context.getPos(), TileEntity::markDirty);
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
} }

View file

@ -94,7 +94,7 @@ public class ExtendoGripRenderHandler {
.rotateY(flip * -135.0F); .rotateY(flip * -135.0F);
ms.translate(flip * 5.6F, 0.0F, 0.0F); ms.translate(flip * 5.6F, 0.0F, 0.0F);
msr.rotateY(flip * 40.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() PlayerRenderer playerrenderer = (PlayerRenderer) mc.getRenderManager()
.getRenderer(player); .getRenderer(player);
@ -115,14 +115,14 @@ public class ExtendoGripRenderHandler {
if (!notInOffhand) { if (!notInOffhand) {
ForgeHooksClient.handleCameraTransforms(ms, mc.getItemRenderer() 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(flip * -.05f, .15f, -1.2f);
ms.translate(0, 0, -animation * 2.25f); ms.translate(0, 0, -animation * 2.25f);
if (blockItem && mc.getItemRenderer() if (blockItem && mc.getItemRenderer()
.getItemModelWithOverrides(heldItem, null, null) .getItemModelWithOverrides(heldItem, null, null)
.isGui3d()) { .isGui3d()) {
msr.rotateY(45); msr.rotateY(flip * 45);
ms.translate(0.15f, -0.15f, -.05f); ms.translate(flip * 0.15f, -0.15f, -.05f);
ms.scale(1.25f, 1.25f, 1.25f); ms.scale(1.25f, 1.25f, 1.25f);
} }