Fix map generation on mine a diamond challenge.

This commit is contained in:
Thanos paravantis 2016-01-08 17:35:17 +02:00
parent e114b623bd
commit 45c40f5568
2 changed files with 26 additions and 12 deletions

View File

@ -1 +1 @@
{}
[[{"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"]]

View File

@ -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 if (y == 1)
{
if (absX == getArenaSize() || absZ == getArenaSize())
{
if (UtilMath.random.nextBoolean())
b.setType(Material.STONE);
else
b.setType(Material.COBBLESTONE);
}
else
{
if (amountOfDiamonds == 0)
{
if (y <= 1)
{
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)
}
else if (y == 2 && (absX == getArenaSize() || absZ == getArenaSize()))
{
b.setType(Material.FENCE);
}
}
if (b.getType() != Material.AIR)
{
addBlock(b);