From 45c40f5568d338fb013066aa3a4c64e3e6df291b Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Fri, 8 Jan 2016 17:35:17 +0200 Subject: [PATCH] Fix map generation on mine a diamond challenge. --- .../identified-project-coordinates.json | 2 +- .../challenges/ChallengeMineADiamond.java | 36 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.recommenders/caches/identified-project-coordinates.json b/.recommenders/caches/identified-project-coordinates.json index 9e26dfeeb..e29ed9b61 100644 --- a/.recommenders/caches/identified-project-coordinates.json +++ b/.recommenders/caches/identified-project-coordinates.json @@ -1 +1 @@ -{} \ No newline at end of file +[[{"location":"C:\\Program Files\\Java\\jre1.8.0_51","type":"JRE","hints":{}},"jre:jre:1.8.0"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Nautilus.Game.Arcade","type":"PROJECT","hints":{"PROJECT_NAME":"Nautilus.Game.Arcade"}},"ABSENT"]] \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMineADiamond.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMineADiamond.java index b4bcadec6..48be058a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMineADiamond.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMineADiamond.java @@ -60,23 +60,27 @@ public class ChallengeMineADiamond extends Challenge { player.getInventory().addItem(new ItemStack(Material.DIAMOND_PICKAXE)); } - for(Block diamond: _diamonds) + for (Block diamond : _diamonds) { - diamond.setType(Material.DIAMOND); + diamond.setType(Material.DIAMOND_ORE); } Host.BlockBreak = true; } + @SuppressWarnings("deprecation") @Override public void generateRoom() { int amountOfDiamonds = 0; + for (int x = -getArenaSize(); x <= getArenaSize(); x++) { for (int z = -getArenaSize(); z <= getArenaSize(); z++) { for (int y = 0; y <= 2; y++) { + double absX = Math.abs(x); + double absZ = Math.abs(z); Block b = getCenter().getBlock().getRelative(x, y, z); if (y == 0) @@ -84,39 +88,49 @@ public class ChallengeMineADiamond extends Challenge b.setType(Material.DIRT); b.setData((byte) 2); } - else + else if (y == 1) { - if (amountOfDiamonds == 0) + if (absX == getArenaSize() || absZ == getArenaSize()) { - if (y <= 1) + if (UtilMath.random.nextBoolean()) + b.setType(Material.STONE); + else + b.setType(Material.COBBLESTONE); + } + else + { + if (amountOfDiamonds == 0) { for (int i = 0; i < Math.ceil((Host.GetPlayers(true).size() + 1) / 2); i++) { Block copy = getCenter().getBlock().getRelative( UtilMath.r(getArenaSize() * 2) - (getArenaSize()), 1, UtilMath.r(getArenaSize() * 2) - (getArenaSize())); - if (copy.getType() == Material.DIAMOND_ORE) + + if (copy.getType() == Material.DIAMOND_ORE && Math.abs(copy.getX()) < getArenaSize() && Math.abs(copy.getY()) < getArenaSize()) { i--; continue; } + _diamonds.add(copy); addBlock(copy); amountOfDiamonds++; } } + if (b.getType() != Material.DIAMOND_ORE) { b.setType(_ores.get(UtilMath.r(_ores.size()))); } } - - if ((Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize()) && y >= 2) - { - b.setType(Material.FENCE); - } } + else if (y == 2 && (absX == getArenaSize() || absZ == getArenaSize())) + { + b.setType(Material.FENCE); + } + if (b.getType() != Material.AIR) { addBlock(b);