Simplify the rescue totem: keep the platform and ladder and disallow breaking blocks
This commit is contained in:
1 parent
7e85a6d229
commit
555f4024e4
2 files changed
+5
-31
No files matched your search
@@ -65,11 +65,7 @@ public class EndlessJumper {
|
||||
else generator.onMove(event.getNewPosition());
|
||||
});
|
||||
|
||||
// nur Brücken- und Rettungsblöcke dürfen abgebaut werden (Notausgang), Streckenblöcke nie
|
||||
eventHandler.addListener(PlayerBlockBreakEvent.class, event -> {
|
||||
JumpGenerator generator = games.get(event.getPlayer());
|
||||
if(generator == null || !generator.isBreakable(event.getBlockPosition())) event.setCancelled(true);
|
||||
});
|
||||
eventHandler.addListener(PlayerBlockBreakEvent.class, event -> event.setCancelled(true));
|
||||
eventHandler.addListener(PlayerBlockPlaceEvent.class, event -> event.setCancelled(true));
|
||||
eventHandler.addListener(ItemDropEvent.class, event -> event.setCancelled(true));
|
||||
eventHandler.addListener(PlayerSwapItemEvent.class, event -> event.setCancelled(true));
|
||||
|
||||
@@ -77,8 +77,7 @@ public class JumpGenerator {
|
||||
private int bridgeStart = -1;
|
||||
private int bridgeEnd = -1;
|
||||
|
||||
// Rettung durch das Totem: Plattform mit Leiter unter dem Block, von dem man gefallen ist
|
||||
private final Map<Pos, Block> rescueBlocks = new HashMap<>();
|
||||
// laufende Rettung durch das Totem: der Block, auf den man über die Leiter zurückklettert
|
||||
private Pos rescueSafe;
|
||||
|
||||
/** @param startIndex Fortschritt, ab dem gespielt wird (0 oder ein gespeicherter Checkpoint) */
|
||||
@@ -288,9 +287,9 @@ public class JumpGenerator {
|
||||
double y = this.player.getPosition().y();
|
||||
|
||||
if(this.rescueSafe != null) {
|
||||
if(y >= this.rescueSafe.y() + 0.9) this.endRescue();
|
||||
if(y >= this.rescueSafe.y() + 0.9) this.rescueSafe = null;
|
||||
else if(y < this.rescueSafe.blockY() - RESCUE_DEPTH - 3) {
|
||||
this.endRescue();
|
||||
this.rescueSafe = null;
|
||||
this.reset();
|
||||
}
|
||||
return;
|
||||
@@ -332,23 +331,7 @@ public class JumpGenerator {
|
||||
/** Brückenglas darf überschrieben werden, sonst könnte ein früherer Brückenweg die Leiter versperren. */
|
||||
private void placeRescue(Pos pos, Block block) {
|
||||
Block existing = this.world.getBlock(pos);
|
||||
if(!existing.compare(Block.AIR) && !existing.compare(BRIDGE_BLOCK)) return;
|
||||
this.world.setBlock(pos, block);
|
||||
this.rescueBlocks.put(pos, block);
|
||||
}
|
||||
|
||||
private void endRescue() {
|
||||
this.rescueSafe = null;
|
||||
Map<Pos, Block> placed = Map.copyOf(this.rescueBlocks);
|
||||
this.rescueBlocks.clear();
|
||||
removeLater(this.world, placed);
|
||||
}
|
||||
|
||||
/** Entfernt nur, was noch unverändert steht (Rettungsblöcke dürfen abgebaut werden). */
|
||||
private static void removeLater(Instance world, Map<Pos, Block> placed) {
|
||||
world.scheduler().buildTask(() -> placed.forEach((pos, block) -> {
|
||||
if(world.getBlock(pos).compare(block)) world.setBlock(pos, Block.AIR);
|
||||
})).delay(TaskSchedule.seconds(8)).schedule();
|
||||
if(existing.compare(Block.AIR) || existing.compare(BRIDGE_BLOCK)) this.world.setBlock(pos, block);
|
||||
}
|
||||
|
||||
/** Beendet alles, was an den Spieler gebunden weiterläuft (Partikel, Musik). */
|
||||
@@ -356,11 +339,6 @@ public class JumpGenerator {
|
||||
this.atmosphere.stop();
|
||||
}
|
||||
|
||||
/** Streckenblöcke und ihr Licht sind geschützt, alles andere (Brücke, Rettung) darf abgebaut werden. */
|
||||
public boolean isBreakable(Point pos) {
|
||||
return !this.world.getBlock(pos).compare(Block.LIGHT) && !this.courseIndex.containsKey(BlockKey.of(pos));
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
this.player.teleport(this.checkpoint.add(0.5, 1, 0.5));
|
||||
this.combo = 0;
|
||||
|
||||
Reference in new issue
Block a user