From 44a3313c1269a2d02390f6951210197782c274ee Mon Sep 17 00:00:00 2001 From: Nick Smit Date: Sat, 30 Jan 2021 22:39:09 +0100 Subject: [PATCH] Added the 'Paused' instruction for sequenced gearshift, which waits for another redstone pulse to continue. --- .../resources/assets/create/lang/en_us.json | 1 + .../advanced/sequencer/Instruction.java | 13 +++++++++++++ .../advanced/sequencer/OnIsPoweredResult.java | 6 ++++++ .../sequencer/SequencedGearshiftBlock.java | 5 ++++- .../SequencedGearshiftTileEntity.java | 16 ++++++++++++++++ .../sequencer/SequencerInstructions.java | 1 + .../create/foundation/gui/AllGuiTextures.java | 1 + .../assets/create/textures/gui/sequencer.png | Bin 1696 -> 17289 bytes 8 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/simibubi/create/content/contraptions/relays/advanced/sequencer/OnIsPoweredResult.java 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 5dcbea527b17911cdc72bbf8be0f96e607950def..a06270d229ee28312255b55c8410c7d88c844276 100644 GIT binary patch literal 17289 zcmeI3c~}$I7QiP!tfq^$VzEA64RJxlkc|)$!zLi0?1WVjvP>X_EG7X0h#*?`x}yRr zs8nsGpj8o95Ean6;l3h>EQ*RdE(q@?Y;nZ-?0fC^zW2TvKE9cA&pqef`#a~JJNaW4 z_U&>Mod4jKht7z3+`0ys({vm><}C?OFgB0Ewr(~Ih*aE7BL z?nz2GAjz92Oo|b*MI;A%0$0NU4y3S}Pt-_bWh#!wj->O;0ngfI3W=!eqK>g6IcWzZ zhIsiBo#jfH$h5K{3#m3NB8zQBW3pJ*tZ_s-mByq{859PUOlNScsT^xMvFjq)6TlN! zDH3!1T_$!72P8XEv|6p;P$&rr304UVE4ea?LSwVp6e^uUr;|YsvMN!g=4;3@)rd|f z-F{qPl~5^Bs3me4QR|m4kjJU*NF?n*Jy+Mdq>7$_WU4N9fFec1S5RnHR7zh)B4Lk> zB2F2ro0>>Sfn#AQEK{q19j#A0MYLQkS4GP|GGveXqXUDOczN}V-RFFz(msb)sa@j% zf-a-73Yg*#tK@M?A?z9t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