mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 22:13:40 +01:00
Added the 'Paused' instruction for sequenced gearshift, which waits for another redstone pulse to continue.
This commit is contained in:
parent
2315625c4b
commit
44a3313c12
8 changed files with 42 additions and 1 deletions
|
@ -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",
|
||||
|
|
|
@ -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<Instruction> instructions) {
|
||||
ListNBT list = new ListNBT();
|
||||
instructions.forEach(i -> list.add(i.serialize()));
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.relays.advanced.sequencer;
|
||||
|
||||
public enum OnIsPoweredResult {
|
||||
NOTHING,
|
||||
CONTINUE
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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),
|
||||
|
||||
;
|
||||
|
|
|
@ -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),
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 17 KiB |
Loading…
Reference in a new issue