Merge pull request #962 from CookieNick/mc1.15/paused-sequenced-gearshift

Added the 'Paused' instruction for sequenced gearshift
This commit is contained in:
simibubi 2021-02-19 15:10:14 +01:00 committed by GitHub
commit 2ece21a3ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 1 deletions

View file

@ -851,6 +851,7 @@
"create.gui.sequenced_gearshift.instruction.turn_distance.distance": "Distance", "create.gui.sequenced_gearshift.instruction.turn_distance.distance": "Distance",
"create.gui.sequenced_gearshift.instruction.wait": "Wait", "create.gui.sequenced_gearshift.instruction.wait": "Wait",
"create.gui.sequenced_gearshift.instruction.wait.duration": "Duration", "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.instruction.end": "End",
"create.gui.sequenced_gearshift.speed": "Speed, Direction", "create.gui.sequenced_gearshift.speed": "Speed, Direction",
"create.gui.sequenced_gearshift.speed.forward": "Input speed, Forwards", "create.gui.sequenced_gearshift.speed.forward": "Input speed, Forwards",

View file

@ -41,6 +41,9 @@ public class Instruction {
case WAIT: case WAIT:
return (int) ((1 - initialProgress) * value + 1); return (int) ((1 - initialProgress) * value + 1);
case PAUSED:
return -1;
case END: case END:
default: default:
break; break;
@ -58,6 +61,7 @@ public class Instruction {
case END: case END:
case WAIT: case WAIT:
case PAUSED:
default: default:
break; break;
@ -65,6 +69,15 @@ public class Instruction {
return 0; return 0;
} }
OnIsPoweredResult onIsPowered() {
switch (instruction)
{
case PAUSED:
return OnIsPoweredResult.CONTINUE;
}
return OnIsPoweredResult.NOTHING;
}
public static ListNBT serializeAll(Vector<Instruction> instructions) { public static ListNBT serializeAll(Vector<Instruction> instructions) {
ListNBT list = new ListNBT(); ListNBT list = new ListNBT();
instructions.forEach(i -> list.add(i.serialize())); instructions.forEach(i -> list.add(i.serialize()));

View file

@ -0,0 +1,6 @@
package com.simibubi.create.content.contraptions.relays.advanced.sequencer;
public enum OnIsPoweredResult {
NOTHING,
CONTINUE
}

View file

@ -64,8 +64,11 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock implemen
return; return;
boolean previouslyPowered = state.get(STATE) != 0; boolean previouslyPowered = state.get(STATE) != 0;
if (previouslyPowered != worldIn.isBlockPowered(pos)) boolean isPowered = worldIn.isBlockPowered(pos);
if (previouslyPowered != isPowered)
withTileEntityDo(worldIn, pos, SequencedGearshiftTileEntity::onRedstoneUpdate); withTileEntityDo(worldIn, pos, SequencedGearshiftTileEntity::onRedstoneUpdate);
else if (isPowered)
withTileEntityDo(worldIn, pos, SequencedGearshiftTileEntity::onIsPowered);
} }
@Override @Override

View file

@ -32,6 +32,8 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity {
return; return;
if (world.isRemote) if (world.isRemote)
return; return;
if (currentInstructionDuration < 0)
return;
if (timer < currentInstructionDuration) { if (timer < currentInstructionDuration) {
timer++; timer++;
return; return;
@ -66,6 +68,7 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity {
public void onRedstoneUpdate() { public void onRedstoneUpdate() {
if (!isIdle()) if (!isIdle())
return; return;
if (!world.isBlockPowered(pos)) { if (!world.isBlockPowered(pos)) {
world.setBlockState(pos, getBlockState().with(SequencedGearshiftBlock.STATE, 0), 3); world.setBlockState(pos, getBlockState().with(SequencedGearshiftBlock.STATE, 0), 3);
return; return;
@ -75,6 +78,19 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity {
run(0); 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) { protected void run(int instructionIndex) {
Instruction instruction = getInstruction(instructionIndex); Instruction instruction = getInstruction(instructionIndex);
if (instruction == null || instruction.instruction == SequencerInstructions.END) { if (instruction == null || instruction.instruction == SequencerInstructions.END) {

View file

@ -11,6 +11,7 @@ public enum SequencerInstructions {
TURN_ANGLE("angle", AllGuiTextures.SEQUENCER_INSTRUCTION, true, true, 360, 45, 90), TURN_ANGLE("angle", AllGuiTextures.SEQUENCER_INSTRUCTION, true, true, 360, 45, 90),
TURN_DISTANCE("distance", AllGuiTextures.SEQUENCER_INSTRUCTION, true, true, 128, 5, 5), TURN_DISTANCE("distance", AllGuiTextures.SEQUENCER_INSTRUCTION, true, true, 128, 5, 5),
WAIT("duration", AllGuiTextures.SEQUENCER_WAIT, true, false, 600, 20, 10), WAIT("duration", AllGuiTextures.SEQUENCER_WAIT, true, false, 600, 20, 10),
PAUSED("", AllGuiTextures.SEQUENCER_PAUSED),
END("", AllGuiTextures.SEQUENCER_END), END("", AllGuiTextures.SEQUENCER_END),
; ;

View file

@ -54,6 +54,7 @@ public enum AllGuiTextures {
SEQUENCER_WAIT("sequencer.png", 0, 58, 162, 22), SEQUENCER_WAIT("sequencer.png", 0, 58, 162, 22),
SEQUENCER_END("sequencer.png", 0, 80, 162, 22), SEQUENCER_END("sequencer.png", 0, 80, 162, 22),
SEQUENCER_EMPTY("sequencer.png", 0, 102, 162, 22), SEQUENCER_EMPTY("sequencer.png", 0, 102, 162, 22),
SEQUENCER_PAUSED("sequencer.png", 0, 160, 162, 22),
// JEI // JEI
JEI_SLOT("jei/widgets.png", 18, 18), JEI_SLOT("jei/widgets.png", 18, 18),

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 17 KiB