From bccce7593f5a3d8eca02b9725bf93f0b97cc6e19 Mon Sep 17 00:00:00 2001 From: Thanos Paravantis Date: Sat, 18 Jun 2016 20:56:33 +0300 Subject: [PATCH] Update second Lava Run to patch obsidian bugs --- .../challenge/type/ChallengeLavaRun.java | 105 ++++++++---------- 1 file changed, 44 insertions(+), 61 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java index 9b6dc077f..7facc6b0a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java @@ -28,8 +28,9 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType; */ public class ChallengeLavaRun extends Challenge { + private int _arenaStartSize; private Block _obsidian; - private Block _lastObsidian; + private boolean _shouldMoveObsidian; private List _platform; private int _mapY = 4; private long _delay; @@ -54,6 +55,7 @@ public class ChallengeLavaRun extends Challenge public ArrayList createSpawns() { ArrayList spawns = new ArrayList(); + _arenaStartSize = getArenaSize(); int size = getArenaSize() - 3; for (int x = -size; x <= size; x++) @@ -77,22 +79,54 @@ public class ChallengeLavaRun extends Challenge public void onStart() { _delay = System.currentTimeMillis() + 2000; - _obsidian = generateObsidianBlock(); + _obsidian = createObsidianBlock(); createLava(); disguisePlayers(); } - @Override - public void onEnd() + @EventHandler + public void onUpdate(UpdateEvent event) { - if (_lastObsidian != null) + if (event.getType() != UpdateType.TICK) + return; + + if (!isChallengeValid()) + return; + + if (_delay > System.currentTimeMillis()) + return; + + if (_shouldMoveObsidian) { - addBlock(_lastObsidian); + resetBlock(_obsidian); + generatePlatform(); + _obsidian = createObsidianBlock(); + blockBreakEffect(_obsidian, false); + playSound(); + + _delay = System.currentTimeMillis(); + + if (_delayMin > 0) + { + _delayMin -= 100; + _delay += _delayMin; + } + + _disappearingBlocks++; + _shouldMoveObsidian = false; } - else if (_obsidian != null) + else { - addBlock(_obsidian); + if (isPlatformEmpty()) + { + _delay = System.currentTimeMillis() + 1500; + _shouldMoveObsidian = true; + } + else + { + destroyPlatform(); + } } } @@ -120,53 +154,6 @@ public class ChallengeLavaRun extends Challenge event.AddMod("Ensure Death", null, 9999, false); } - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - if (!isChallengeValid()) - return; - - if (_delay > System.currentTimeMillis()) - return; - - if (_obsidian == null) - { - resetBlock(_lastObsidian); - _obsidian = generateObsidianBlock(); - - generatePlatform(); - setBlock(_obsidian, Material.OBSIDIAN); - blockBreakEffect(_obsidian, false); - playSound(); - - _delay = System.currentTimeMillis(); - - if (_delayMin > 0) - { - _delayMin -= 100; - _delay += _delayMin; - } - - _disappearingBlocks++; - } - else - { - if (isPlatformEmpty()) - { - _delay = System.currentTimeMillis() + 1500; - _lastObsidian = _obsidian; - _obsidian = null; - } - else - { - destroyPlatform(); - } - } - } - private void generatePlatform() { _platform = new ArrayList<>(); @@ -201,13 +188,9 @@ public class ChallengeLavaRun extends Challenge } } - private Block generateObsidianBlock() + private Block createObsidianBlock() { - Block block = getCenter().add( - UtilMath.r(21) - 9.5, - _mapY, - UtilMath.r(21) - 9.5).getBlock(); - + Block block = getCenter().add(UtilMath.r(_arenaStartSize), _mapY, UtilMath.r(_arenaStartSize)).getBlock(); setBlock(block, Material.OBSIDIAN); return block; }