diff --git a/src/generated/resources/assets/create/lang/en_us.json b/src/generated/resources/assets/create/lang/en_us.json index fb30e864a..da439e34c 100644 --- a/src/generated/resources/assets/create/lang/en_us.json +++ b/src/generated/resources/assets/create/lang/en_us.json @@ -844,6 +844,7 @@ "create.gui.sequenced_gearshift.instruction.turn_distance.distance": "Distance", "create.gui.sequenced_gearshift.instruction.wait": "Wait", "create.gui.sequenced_gearshift.instruction.wait.duration": "Duration", + "create.gui.sequenced_gearshift.instruction.paused": "Paused", "create.gui.sequenced_gearshift.instruction.end": "End", "create.gui.sequenced_gearshift.speed": "Speed, Direction", "create.gui.sequenced_gearshift.speed.forward": "Input speed, Forwards", diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/Instruction.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/Instruction.java index b28c352f2..fc9e53bb0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/Instruction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/Instruction.java @@ -41,6 +41,9 @@ public class Instruction { case WAIT: return (int) ((1 - initialProgress) * value + 1); + case PAUSED: + return -1; + case END: default: break; @@ -58,6 +61,7 @@ public class Instruction { case END: case WAIT: + case PAUSED: default: break; @@ -65,6 +69,15 @@ public class Instruction { return 0; } + OnIsPoweredResult onIsPowered() { + switch (instruction) + { + case PAUSED: + return OnIsPoweredResult.CONTINUE; + } + return OnIsPoweredResult.NOTHING; + } + public static ListNBT serializeAll(Vector instructions) { ListNBT list = new ListNBT(); instructions.forEach(i -> list.add(i.serialize())); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/OnIsPoweredResult.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/OnIsPoweredResult.java new file mode 100644 index 000000000..e942da652 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/OnIsPoweredResult.java @@ -0,0 +1,6 @@ +package com.simibubi.create.content.contraptions.relays.advanced.sequencer; + +public enum OnIsPoweredResult { + NOTHING, + CONTINUE +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java index 2974f2a3a..a5b2d3157 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftBlock.java @@ -64,8 +64,11 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen return; boolean previouslyPowered = state.get(STATE) != 0; - if (previouslyPowered != worldIn.isBlockPowered(pos)) + boolean isPowered = worldIn.isBlockPowered(pos); + if (previouslyPowered != isPowered) withTileEntityDo(worldIn, pos, SequencedGearshiftTileEntity::onRedstoneUpdate); + else if (isPowered) + withTileEntityDo(worldIn, pos, SequencedGearshiftTileEntity::onIsPowered); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftTileEntity.java index b52e47ee2..ff73551d1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencedGearshiftTileEntity.java @@ -32,6 +32,8 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity { return; if (world.isRemote) return; + if (currentInstructionDuration < 0) + return; if (timer < currentInstructionDuration) { timer++; return; @@ -66,6 +68,7 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity { public void onRedstoneUpdate() { if (!isIdle()) return; + if (!world.isBlockPowered(pos)) { world.setBlockState(pos, getBlockState().with(SequencedGearshiftBlock.STATE, 0), 3); return; @@ -75,6 +78,19 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity { run(0); } + public void onIsPowered() { + + Instruction instruction = getInstruction(currentInstruction); + if (instruction == null) + return; + + switch (instruction.onIsPowered()) + { + case CONTINUE: + run(currentInstruction + 1); + } + } + protected void run(int instructionIndex) { Instruction instruction = getInstruction(instructionIndex); if (instruction == null || instruction.instruction == SequencerInstructions.END) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java index 3bb06ba8e..ba3ee45d7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/SequencerInstructions.java @@ -11,6 +11,7 @@ public enum SequencerInstructions { TURN_ANGLE("angle", AllGuiTextures.SEQUENCER_INSTRUCTION, true, true, 360, 45, 90), TURN_DISTANCE("distance", AllGuiTextures.SEQUENCER_INSTRUCTION, true, true, 128, 5, 5), WAIT("duration", AllGuiTextures.SEQUENCER_WAIT, true, false, 600, 20, 10), + PAUSED("", AllGuiTextures.SEQUENCER_PAUSED), END("", AllGuiTextures.SEQUENCER_END), ; diff --git a/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java b/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java index 5528f791b..87fc23222 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java @@ -54,6 +54,7 @@ public enum AllGuiTextures { SEQUENCER_WAIT("sequencer.png", 0, 58, 162, 22), SEQUENCER_END("sequencer.png", 0, 80, 162, 22), SEQUENCER_EMPTY("sequencer.png", 0, 102, 162, 22), + SEQUENCER_PAUSED("sequencer.png", 0, 160, 162, 22), // JEI JEI_SLOT("jei/widgets.png", 18, 18), diff --git a/src/main/resources/assets/create/textures/gui/sequencer.png b/src/main/resources/assets/create/textures/gui/sequencer.png index 5dcbea527..a06270d22 100644 Binary files a/src/main/resources/assets/create/textures/gui/sequencer.png and b/src/main/resources/assets/create/textures/gui/sequencer.png differ