Fix some lifetime and offset contraints for RedstonePhases
Dieser Commit ist enthalten in:
Ursprung
fdc201e99d
Commit
a0ff726fb4
@ -63,6 +63,9 @@ public class SimulatorGroupChooserGui extends SimulatorPageGui<SimulatorGroup> {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
inventory.addCloseCallback(clickType -> {
|
||||||
|
back.open();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -140,7 +140,6 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
||||||
// TODO: Change X Anvil GUI
|
|
||||||
}));
|
}));
|
||||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||||
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0);
|
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0);
|
||||||
@ -153,7 +152,6 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
||||||
// TODO: Change Y Anvil GUI
|
|
||||||
}));
|
}));
|
||||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||||
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0);
|
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0);
|
||||||
@ -166,7 +164,6 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
||||||
// TODO: Change Z Anvil GUI
|
|
||||||
}));
|
}));
|
||||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||||
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1);
|
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1);
|
||||||
|
@ -119,7 +119,6 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SWItem[] column(RedstoneSubPhase redstoneSubPhase, int index) {
|
public SWItem[] column(RedstoneSubPhase redstoneSubPhase, int index) {
|
||||||
// TODO: Add to the phase edit menus and split those to better reflect the scroll gui state
|
|
||||||
int min;
|
int min;
|
||||||
if (index % 2 == 0 && index > 0) {
|
if (index % 2 == 0 && index > 0) {
|
||||||
RedstoneSubPhase subPhase = data.get(index - 1);
|
RedstoneSubPhase subPhase = data.get(index - 1);
|
||||||
|
@ -74,17 +74,37 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
int index = redstoneElement.getPhases().indexOf(redstone);
|
||||||
|
int min;
|
||||||
|
if (index > 0) {
|
||||||
|
RedstonePhase previous = redstoneElement.getPhases().get(index - 1);
|
||||||
|
min = previous.getTickOffset() + previous.getLifetime() + 1;
|
||||||
|
} else {
|
||||||
|
min = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxLifetime;
|
||||||
|
int maxOffset;
|
||||||
|
if (index < redstoneElement.getPhases().size() - 1) {
|
||||||
|
RedstonePhase next = redstoneElement.getPhases().get(index + 1);
|
||||||
|
maxLifetime = next.getTickOffset() - redstone.getTickOffset() - 1;
|
||||||
|
maxOffset = next.getTickOffset() - redstone.getLifetime() - 1;
|
||||||
|
} else {
|
||||||
|
maxLifetime = Integer.MAX_VALUE - 5;
|
||||||
|
maxOffset = Integer.MAX_VALUE - 5;
|
||||||
|
}
|
||||||
|
|
||||||
//Tick Offset
|
//Tick Offset
|
||||||
int offset = redstone.getTickOffset();
|
int offset = redstone.getTickOffset();
|
||||||
inventory.setItem(10, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
inventory.setItem(10, SWItem.getDye(offset < maxOffset ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||||
redstone.setTickOffset(offset + (clickType.isShiftClick() ? 5 : 1));
|
redstone.setTickOffset(Math.min(maxOffset, offset + (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
|
|
||||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||||
if (integer < 0) return false;
|
if (integer < 0) return false;
|
||||||
redstone.setTickOffset(integer);
|
redstone.setTickOffset(Math.min(Math.max(integer, min), maxOffset));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
return true;
|
return true;
|
||||||
}, this).setItem(Material.REPEATER).open();
|
}, this).setItem(Material.REPEATER).open();
|
||||||
@ -92,22 +112,22 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||||
inventory.setItem(19, offsetItem);
|
inventory.setItem(19, offsetItem);
|
||||||
|
|
||||||
inventory.setItem(28, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
inventory.setItem(28, SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||||
redstone.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1)));
|
redstone.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
|
|
||||||
//Lifetime
|
//Lifetime
|
||||||
int lifetime = redstone.getLifetime();
|
int lifetime = redstone.getLifetime();
|
||||||
inventory.setItem(11, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
inventory.setItem(11, SWItem.getDye(lifetime < maxLifetime ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||||
redstone.setLifetime(lifetime + (clickType.isShiftClick() ? 5 : 1));
|
redstone.setLifetime(Math.min(maxLifetime, lifetime + (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
|
|
||||||
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> {
|
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Activation Time", lifetime + "", Integer::parseInt, integer -> {
|
new SimulatorAnvilGui<>(player, "Activation Time", lifetime + "", Integer::parseInt, integer -> {
|
||||||
if (integer < 0) return false;
|
if (integer < 0) return false;
|
||||||
redstone.setLifetime(integer);
|
redstone.setLifetime(Math.min(integer, maxLifetime));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
return true;
|
return true;
|
||||||
}, this).setItem(Material.CLOCK).open();
|
}, this).setItem(Material.CLOCK).open();
|
||||||
|
@ -33,7 +33,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SimulatorTNTSettingsGui extends SimulatorBaseGui { // TODO: Anvil GUI's!
|
public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||||
private final TNTElement tnt;
|
private final TNTElement tnt;
|
||||||
private final SimulatorBaseGui back;
|
private final SimulatorBaseGui back;
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren