fixed furnaces in undead camp
This commit is contained in:
parent
08f683aa98
commit
521aa8d965
@ -5,10 +5,10 @@ import org.bukkit.material.MaterialData;
|
||||
|
||||
public enum CampType
|
||||
{
|
||||
OAK(new MaterialData(Material.LOG, (byte) 0), new MaterialData(Material.WOOD, (byte) 0), Material.ENDER_CHEST, Material.BURNING_FURNACE),
|
||||
SPRUCE(new MaterialData(Material.LOG, (byte) 1), new MaterialData(Material.WOOD, (byte) 1), Material.ENDER_CHEST, Material.BURNING_FURNACE),
|
||||
BIRCH(new MaterialData(Material.LOG, (byte) 2), new MaterialData(Material.WOOD, (byte) 2), Material.ENDER_CHEST, Material.BURNING_FURNACE),
|
||||
JUNGLE(new MaterialData(Material.LOG, (byte) 3), new MaterialData(Material.WOOD, (byte) 3), Material.ENDER_CHEST, Material.BURNING_FURNACE);
|
||||
OAK(new MaterialData(Material.LOG, (byte) 0), new MaterialData(Material.WOOD, (byte) 0), Material.ENDER_CHEST, Material.FURNACE),
|
||||
SPRUCE(new MaterialData(Material.LOG, (byte) 1), new MaterialData(Material.WOOD, (byte) 1), Material.ENDER_CHEST, Material.FURNACE),
|
||||
BIRCH(new MaterialData(Material.LOG, (byte) 2), new MaterialData(Material.WOOD, (byte) 2), Material.ENDER_CHEST, Material.FURNACE),
|
||||
JUNGLE(new MaterialData(Material.LOG, (byte) 3), new MaterialData(Material.WOOD, (byte) 3), Material.ENDER_CHEST, Material.FURNACE);
|
||||
|
||||
private MaterialData _log;
|
||||
private MaterialData _wood;
|
||||
|
@ -35,29 +35,28 @@ public class UndeadCamp extends WorldEvent
|
||||
private int _poleLeft = 0;
|
||||
private int _towerLeft = 0;
|
||||
private int _undeadCount = 0;
|
||||
|
||||
|
||||
private final CampType _campType;
|
||||
private final CampSize _campSize;
|
||||
private Set<Block> _chests;
|
||||
private Set<Block> _containers;
|
||||
private WorldEventManager _eventManager;
|
||||
|
||||
private SkillFactory _skillFactory;
|
||||
|
||||
public UndeadCamp(WorldEventManager eventManager, Location centerLocation, SkillFactory skillFactory)
|
||||
{
|
||||
super(eventManager.getClans().getDisguiseManager(), eventManager.getClans().getProjectile(), eventManager.getDamage(),
|
||||
eventManager.getBlockRestore(), eventManager.getClans().getCondition(), "Undead Camp", centerLocation);
|
||||
|
||||
super(eventManager.getClans().getDisguiseManager(), eventManager.getClans().getProjectile(), eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), "Undead Camp", centerLocation);
|
||||
|
||||
_eventManager = eventManager;
|
||||
_campSize = CampSize.getCampSize(UtilServer.getPlayers().length);
|
||||
_campType = CampType.values()[getRandom().nextInt(CampType.values().length)];
|
||||
_chests = new HashSet<Block>();
|
||||
|
||||
_containers = new HashSet<Block>();
|
||||
|
||||
_hutLeft = _campSize.generateHutCount();
|
||||
_poleLeft = _campSize.generatePoleCount();
|
||||
_towerLeft = _campSize.generateTowerCount();
|
||||
_undeadCount = _campSize.generateUndeadCount();
|
||||
|
||||
|
||||
setName(_campSize.getName());
|
||||
|
||||
_skillFactory = skillFactory;
|
||||
@ -67,22 +66,26 @@ public class UndeadCamp extends WorldEvent
|
||||
{
|
||||
return _eventManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void customStart()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void customTick()
|
||||
{
|
||||
if (getState() == EventState.PREPARE)
|
||||
{
|
||||
if (_hutLeft > 0) createHut();
|
||||
else if (_towerLeft > 0) createTower();
|
||||
else if (_poleLeft > 0) createLamp();
|
||||
else if (getCreatures().size() < _undeadCount) createUndead();
|
||||
if (_hutLeft > 0)
|
||||
createHut();
|
||||
else if (_towerLeft > 0)
|
||||
createTower();
|
||||
else if (_poleLeft > 0)
|
||||
createLamp();
|
||||
else if (getCreatures().size() < _undeadCount)
|
||||
createUndead();
|
||||
else
|
||||
{
|
||||
System.out.println("Constructed " + getName() + " at " + UtilWorld.locToStrClean(getCenterLocation()) + ".");
|
||||
@ -91,342 +94,418 @@ public class UndeadCamp extends WorldEvent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createHut()
|
||||
{
|
||||
int hutX = UtilMath.r(4) + 2;
|
||||
int hutZ = UtilMath.r(4) + 2;
|
||||
int hutY = UtilMath.r(2) + 3;
|
||||
|
||||
int buffer = Math.max(hutX, hutZ)/2 + 1;
|
||||
|
||||
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded()-buffer, hutX, hutY+2, hutZ, true, false, getBlocks().getChangedBlocks());
|
||||
|
||||
if (loc == null)
|
||||
return;
|
||||
|
||||
|
||||
int buffer = Math.max(hutX, hutZ) / 2 + 1;
|
||||
|
||||
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded() - buffer, hutX, hutY + 2, hutZ, true, false, getBlocks().getChangedBlocks());
|
||||
|
||||
if (loc == null) return;
|
||||
|
||||
boolean xWall = (Math.random() > 0.5);
|
||||
boolean zWall = (Math.random() > 0.5);
|
||||
|
||||
//Base
|
||||
|
||||
// Base
|
||||
for (int x = -hutX; x <= hutX; x++)
|
||||
for (int z = -hutZ; z <=hutZ ; z++)
|
||||
for (int z = -hutZ; z <= hutZ; z++)
|
||||
{
|
||||
Block block = loc.getBlock().getRelative(x, -1, z);
|
||||
|
||||
//Space
|
||||
for (int y=0 ; y<=hutY ; y++)
|
||||
|
||||
// Space
|
||||
for (int y = 0; y <= hutY; y++)
|
||||
setBlock(loc.getBlock().getRelative(x, y, z), 0, (byte) 0);
|
||||
|
||||
//Walls
|
||||
if (!xWall && x == -hutX || xWall && x == hutX || !zWall && z == -hutZ || zWall && z == hutZ)
|
||||
for (int y = 0; y <=hutY ; y++)
|
||||
setBlock(loc.getBlock().getRelative(x, y, z), _campType.getWood().getItemTypeId(), _campType.getWood().getData());
|
||||
|
||||
//Corners
|
||||
|
||||
// Walls
|
||||
if (!xWall && x == -hutX || xWall && x == hutX || !zWall && z == -hutZ || zWall && z == hutZ) for (int y = 0; y <= hutY; y++)
|
||||
setBlock(loc.getBlock().getRelative(x, y, z), _campType.getWood().getItemTypeId(), _campType.getWood().getData());
|
||||
|
||||
// Corners
|
||||
if (Math.abs(x) == hutX && Math.abs(z) == hutZ)
|
||||
{
|
||||
setBlock(block, _campType.getLog().getItemTypeId(), _campType.getLog().getData());
|
||||
for (int y=0 ; y<=hutY ; y++)
|
||||
for (int y = 0; y <= hutY; y++)
|
||||
setBlock(loc.getBlock().getRelative(x, y, z), _campType.getLog().getItemTypeId(), _campType.getLog().getData());
|
||||
|
||||
//Support Stands
|
||||
|
||||
// Support Stands
|
||||
boolean support = true;
|
||||
Block below = block;
|
||||
while (support)
|
||||
{
|
||||
below = below.getRelative(BlockFace.DOWN);
|
||||
|
||||
|
||||
if (!UtilBlock.fullSolid(below) || below.isLiquid())
|
||||
setBlock(below, _campType.getLog().getItemTypeId(), _campType.getLog().getData());
|
||||
|
||||
|
||||
else
|
||||
support = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Floor & Roof
|
||||
|
||||
// Floor & Roof
|
||||
else
|
||||
{
|
||||
setBlock(block, _campType.getWood().getItemTypeId(), _campType.getWood().getData());
|
||||
setBlock(loc.getBlock().getRelative(x, hutY-1, z), 126, (byte)8);
|
||||
setBlock(loc.getBlock().getRelative(x, hutY - 1, z), 126, (byte) 8);
|
||||
}
|
||||
|
||||
//Insides
|
||||
|
||||
// Insides
|
||||
if (Math.abs(x) != hutX && Math.abs(z) != hutZ)
|
||||
{
|
||||
if (Math.random() > 0.90)
|
||||
{
|
||||
addChest(block.getRelative(BlockFace.UP));
|
||||
|
||||
}
|
||||
else if (Math.random() > 0.95)
|
||||
{
|
||||
addFurnace(block.getRelative(BlockFace.UP));
|
||||
|
||||
}
|
||||
else if (Math.random() > 0.95)
|
||||
{
|
||||
registerCreature(new UndeadWarrior(this, block.getRelative(BlockFace.UP).getLocation().add(0.5, 0.5, 0.5)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_hutLeft--;
|
||||
}
|
||||
|
||||
|
||||
private void addChest(Block chest)
|
||||
{
|
||||
Block side;
|
||||
int adj = 0;
|
||||
|
||||
|
||||
side = chest.getRelative(BlockFace.NORTH);
|
||||
if (side.getType() == Material.CHEST)
|
||||
{
|
||||
adj++;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return;
|
||||
}
|
||||
|
||||
|
||||
side = chest.getRelative(BlockFace.SOUTH);
|
||||
if (side.getType() == Material.CHEST)
|
||||
{
|
||||
adj++;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return;
|
||||
}
|
||||
|
||||
|
||||
side = chest.getRelative(BlockFace.EAST);
|
||||
if (side.getType() == Material.CHEST)
|
||||
{
|
||||
adj++;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return;
|
||||
}
|
||||
|
||||
|
||||
side = chest.getRelative(BlockFace.WEST);
|
||||
if (side.getType() == Material.CHEST)
|
||||
{
|
||||
adj++;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.CHEST) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.CHEST) return;
|
||||
}
|
||||
|
||||
if (adj > 1)
|
||||
return;
|
||||
|
||||
setBlock(chest, 130, (byte)(UtilMath.r(4) + 2));
|
||||
_chests.add(chest);
|
||||
|
||||
if (adj > 1) return;
|
||||
|
||||
setBlock(chest, 130, (byte) (UtilMath.r(4) + 2));
|
||||
_containers.add(chest);
|
||||
}
|
||||
|
||||
|
||||
private void addFurnace(Block chest)
|
||||
|
||||
private void addFurnace(Block furnace)
|
||||
{
|
||||
setBlock(chest, Material.BURNING_FURNACE, (byte) (UtilMath.r(4) + 2));
|
||||
_chests.add(chest);
|
||||
Block side;
|
||||
int adj = 0;
|
||||
|
||||
side = furnace.getRelative(BlockFace.NORTH);
|
||||
if (side.getType() == Material.FURNACE)
|
||||
{
|
||||
adj++;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.FURNACE) return;
|
||||
}
|
||||
|
||||
side = furnace.getRelative(BlockFace.SOUTH);
|
||||
if (side.getType() == Material.FURNACE)
|
||||
{
|
||||
adj++;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.FURNACE) return;
|
||||
}
|
||||
|
||||
side = furnace.getRelative(BlockFace.EAST);
|
||||
if (side.getType() == Material.FURNACE)
|
||||
{
|
||||
adj++;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.FURNACE) return;
|
||||
}
|
||||
|
||||
side = furnace.getRelative(BlockFace.WEST);
|
||||
if (side.getType() == Material.FURNACE)
|
||||
{
|
||||
adj++;
|
||||
if (side.getRelative(BlockFace.NORTH).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.SOUTH).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.EAST).getType() == Material.FURNACE) return;
|
||||
if (side.getRelative(BlockFace.WEST).getType() == Material.FURNACE) return;
|
||||
}
|
||||
|
||||
if (adj > 1) return;
|
||||
|
||||
setBlock(furnace, 61, (byte) 0);
|
||||
_containers.add(furnace);
|
||||
System.out.println(_containers.contains(furnace));
|
||||
}
|
||||
|
||||
|
||||
private void createUndead()
|
||||
{
|
||||
|
||||
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded(), 0, 3, 0, false, true, getBlocks().getChangedBlocks());
|
||||
|
||||
if (loc == null)
|
||||
return;
|
||||
|
||||
|
||||
if (loc == null) return;
|
||||
|
||||
registerCreature(new UndeadWarrior(this, loc.add(0.5, 0.5, 0.5)));
|
||||
|
||||
// _poleLeft--;
|
||||
// ResetIdleTicks();
|
||||
|
||||
// _poleLeft--;
|
||||
// ResetIdleTicks();
|
||||
}
|
||||
|
||||
|
||||
private void createTower()
|
||||
{
|
||||
int towerX = UtilMath.r(3) + 1;
|
||||
int towerZ = UtilMath.r(3) + 1;
|
||||
int towerY = UtilMath.r(4) + 3;
|
||||
|
||||
int buffer = Math.max(towerX, towerZ)/2 + 1;
|
||||
|
||||
|
||||
int buffer = Math.max(towerX, towerZ) / 2 + 1;
|
||||
|
||||
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded() - buffer, towerX, towerY + 2, towerZ, false, true, getBlocks().getChangedBlocks());
|
||||
|
||||
if (loc == null)
|
||||
return;
|
||||
|
||||
|
||||
if (loc == null) return;
|
||||
|
||||
int ladder = UtilMath.r(4);
|
||||
|
||||
|
||||
//Base
|
||||
for (int x=-towerX ; x<=towerX ; x++)
|
||||
for (int z=-towerZ ; z<=towerZ ; z++)
|
||||
|
||||
// Base
|
||||
for (int x = -towerX; x <= towerX; x++)
|
||||
for (int z = -towerZ; z <= towerZ; z++)
|
||||
{
|
||||
Block block = loc.getBlock().getRelative(x, towerY, z);
|
||||
|
||||
//Space
|
||||
for (int y=0 ; y<=towerY ; y++)
|
||||
|
||||
// Space
|
||||
for (int y = 0; y <= towerY; y++)
|
||||
setBlock(loc.getBlock().getRelative(x, y, z), 0, (byte) 0);
|
||||
|
||||
//Corner
|
||||
|
||||
// Corner
|
||||
if (Math.abs(x) == towerX && Math.abs(z) == towerZ)
|
||||
{
|
||||
setBlock(block, _campType.getWood().getItemTypeId(), _campType.getWood().getData());
|
||||
setBlock(block.getRelative(BlockFace.UP), 85, (byte) 0);
|
||||
|
||||
//Support Stands
|
||||
|
||||
// Support Stands
|
||||
boolean support = true;
|
||||
Block below = block;
|
||||
while (support)
|
||||
{
|
||||
below = below.getRelative(BlockFace.DOWN);
|
||||
|
||||
|
||||
if (!UtilBlock.fullSolid(below) && !below.isLiquid())
|
||||
setBlock(below, 85, (byte) 0);
|
||||
|
||||
|
||||
else if (below.isLiquid())
|
||||
setBlock(below, _campType.getLog().getItemTypeId(), _campType.getLog().getData());
|
||||
|
||||
|
||||
else
|
||||
support = false;
|
||||
}
|
||||
|
||||
//Ladder
|
||||
if (ladder == 0 && x == -towerX && z == -towerZ ||
|
||||
ladder == 1 && x == -towerX && z == towerZ ||
|
||||
ladder == 2 && x == towerX && z == -towerZ ||
|
||||
ladder == 3 && x == towerX && z == towerZ)
|
||||
|
||||
// Ladder
|
||||
if (ladder == 0 && x == -towerX && z == -towerZ || ladder == 1 && x == -towerX && z == towerZ || ladder == 2 && x == towerX && z == -towerZ || ladder == 3 && x == towerX && z == towerZ)
|
||||
{
|
||||
boolean laddering = true;
|
||||
below = block;
|
||||
while (laddering)
|
||||
{
|
||||
below = below.getRelative(BlockFace.DOWN);
|
||||
|
||||
|
||||
if (!UtilBlock.fullSolid(below))
|
||||
{
|
||||
setBlock(below, _campType.getWood().getItemTypeId(), _campType.getWood().getData());
|
||||
|
||||
if (ladder == 0) setBlock(below.getRelative(-1, 0, 0), 65, (byte) 4);
|
||||
else if (ladder == 1) setBlock(below.getRelative(-1, 0, 0), 65, (byte) 4);
|
||||
else if (ladder == 2) setBlock(below.getRelative(1, 0, 0), 65, (byte) 5);
|
||||
else if (ladder == 3) setBlock(below.getRelative(1, 0, 0), 65, (byte) 5);
|
||||
|
||||
if (ladder == 0)
|
||||
setBlock(below.getRelative(-1, 0, 0), 65, (byte) 4);
|
||||
else if (ladder == 1)
|
||||
setBlock(below.getRelative(-1, 0, 0), 65, (byte) 4);
|
||||
else if (ladder == 2)
|
||||
setBlock(below.getRelative(1, 0, 0), 65, (byte) 5);
|
||||
else if (ladder == 3) setBlock(below.getRelative(1, 0, 0), 65, (byte) 5);
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
laddering = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Platform
|
||||
|
||||
// Platform
|
||||
else
|
||||
setBlock(block, 126, (byte) 8);
|
||||
|
||||
//Features
|
||||
|
||||
// Features
|
||||
if (Math.random() > 0.95)
|
||||
addChest(block.getRelative(BlockFace.UP));
|
||||
|
||||
else if (Math.random() > 0.95)
|
||||
registerCreature(new UndeadArcher(this, block.getRelative(BlockFace.UP).getLocation().add(0.5, 0.5, 0.5), _skillFactory));
|
||||
|
||||
else if (Math.random() > 0.95) registerCreature(new UndeadArcher(this, block.getRelative(BlockFace.UP).getLocation().add(0.5, 0.5, 0.5), _skillFactory));
|
||||
}
|
||||
|
||||
|
||||
_towerLeft--;
|
||||
}
|
||||
|
||||
|
||||
private void createLamp()
|
||||
{
|
||||
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded(), 0, 4, 0, false, true, getBlocks().getChangedBlocks());
|
||||
|
||||
if (loc == null)
|
||||
return;
|
||||
|
||||
|
||||
if (loc == null) return;
|
||||
|
||||
setBlock(loc.getBlock(), 85, (byte) 0);
|
||||
setBlock(loc.getBlock().getRelative(BlockFace.UP), 85, (byte) 0);
|
||||
setBlock(loc.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP), 50, (byte)0);
|
||||
|
||||
setBlock(loc.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP), 50, (byte) 0);
|
||||
|
||||
_poleLeft--;
|
||||
}
|
||||
|
||||
|
||||
private void openChest(Block block)
|
||||
{
|
||||
_chests.remove(block);
|
||||
|
||||
_containers.remove(block);
|
||||
|
||||
// Effect
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.ENDER_CHEST.getId());
|
||||
|
||||
|
||||
setBlock(block, Material.AIR);
|
||||
|
||||
|
||||
// Loot
|
||||
int count = 1 + UtilMath.r(3);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
getEventManager().getLoot().dropCommon(block.getLocation().add(0.5, 0.5, 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void openFurnace(Block block)
|
||||
{
|
||||
_chests.remove(block);
|
||||
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.BURNING_FURNACE.getId());
|
||||
|
||||
_containers.remove(block);
|
||||
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.FURNACE.getId());
|
||||
|
||||
setBlock(block, Material.AIR);
|
||||
|
||||
for (int i=0 ; i<UtilMath.r(25) ; i++)
|
||||
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5),
|
||||
ItemStackFactory.Instance.CreateStack(Material.IRON_INGOT));
|
||||
|
||||
for (int i=0 ; i<UtilMath.r(25) ; i++)
|
||||
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5),
|
||||
ItemStackFactory.Instance.CreateStack(Material.GOLD_INGOT));
|
||||
|
||||
for (int i=0 ; i<UtilMath.r(25) ; i++)
|
||||
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5),
|
||||
ItemStackFactory.Instance.CreateStack(Material.DIAMOND));
|
||||
|
||||
for (int i=0 ; i<UtilMath.r(25) ; i++)
|
||||
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5),
|
||||
ItemStackFactory.Instance.CreateStack(Material.LEATHER));
|
||||
|
||||
double random = Math.random();
|
||||
|
||||
if (random < .25)
|
||||
{
|
||||
for (int i = 0; i < UtilMath.r(25); i++)
|
||||
{
|
||||
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.IRON_INGOT));
|
||||
}
|
||||
}
|
||||
else if (random < .5)
|
||||
{
|
||||
for (int i = 0; i < UtilMath.r(25); i++)
|
||||
{
|
||||
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.GOLD_INGOT));
|
||||
}
|
||||
}
|
||||
else if (random < .75)
|
||||
{
|
||||
for (int i = 0; i < UtilMath.r(25); i++)
|
||||
{
|
||||
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DIAMOND));
|
||||
}
|
||||
}
|
||||
else if (random < 1)
|
||||
{
|
||||
for (int i = 0; i < UtilMath.r(25); i++)
|
||||
{
|
||||
block.getWorld().dropItemNaturally(block.getLocation().add(0.5, 0.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.LEATHER));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void checkEnd(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.SEC) return;
|
||||
|
||||
// Remove any broken chests/furnaces
|
||||
Iterator<Block> it = _chests.iterator();
|
||||
Iterator<Block> it = _containers.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
Block block = it.next();
|
||||
|
||||
|
||||
if (block.getType() != _campType.getChest() && block.getType() != _campType.getFurnace())
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (_chests.size() == 0)
|
||||
|
||||
if (_containers.size() == 0)
|
||||
{
|
||||
triggerEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onChestOpen(PlayerInteractEvent event)
|
||||
{
|
||||
Block block = event.getClickedBlock();
|
||||
if (_chests.contains(block))
|
||||
event.getPlayer().sendMessage(_containers.contains(block) + "");
|
||||
if (_containers.contains(block))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
if (!Recharge.Instance.use(event.getPlayer(), "Loot Chest", 60000, true, false))
|
||||
return;
|
||||
|
||||
if (block.getType() == Material.ENDER_CHEST) openChest(block);
|
||||
else if (block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE) openFurnace(block);
|
||||
|
||||
updateLastActive();
|
||||
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You smash open an " + F.elem("Undead Chest") + "!"));
|
||||
|
||||
if (block.getType() == Material.ENDER_CHEST)
|
||||
{
|
||||
if (!Recharge.Instance.use(event.getPlayer(), "Loot Chest", 60000, true, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
openChest(block);
|
||||
|
||||
updateLastActive();
|
||||
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You smash open an " + F.elem("Undead Chest") + "!"));
|
||||
}
|
||||
else if (block.getType() == Material.FURNACE)
|
||||
{
|
||||
if (!Recharge.Instance.use(event.getPlayer(), "Loot Furnace", 60000, true, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
openFurnace(block);
|
||||
|
||||
updateLastActive();
|
||||
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You smash open an " + F.elem("Undead Furnace") + "!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user