Fixed greenhouse coordinate tracking.

This commit is contained in:
tastybento 2019-05-17 14:08:59 -07:00
parent 930d29acfc
commit a3f8333a7b
2 changed files with 6 additions and 5 deletions

View File

@ -26,6 +26,7 @@ public class Greenhouse implements DataObject {
@Expose
private Location location;
@Expose
// Min coords are inside, max coords are outside
private BoundingBox boundingBox;
@Expose
private Biome originalBiome;
@ -43,7 +44,7 @@ public class Greenhouse implements DataObject {
public Greenhouse(World world, Walls walls, int ceilingHeight) {
this.location = new Location(world, walls.getMinX(), walls.getFloor(), walls.getMinZ());
Location location2 = new Location(world, walls.getMaxX(), ceilingHeight, walls.getMaxZ());
Location location2 = new Location(world, walls.getMaxX() + 1, ceilingHeight + 1, walls.getMaxZ() + 1);
this.boundingBox = BoundingBox.of(location, location2);
}

View File

@ -124,11 +124,11 @@ public class GreenhouseEvents implements Listener {
User user = User.getInstance(e.getPlayer());
plugin.getManager().getMap().getGreenhouse(e.getBlock().getLocation()).ifPresent(g -> {
// Check to see if wall or roof block broken
if ((e.getBlock().getLocation().getBlockY() == g.getCeilingHeight())
if ((e.getBlock().getLocation().getBlockY() == g.getCeilingHeight() - 1)
|| e.getBlock().getLocation().getBlockX() == (int)g.getBoundingBox().getMinX()
|| e.getBlock().getLocation().getBlockX() == (int)g.getBoundingBox().getMaxX()
|| e.getBlock().getLocation().getBlockZ() == (int)g.getBoundingBox().getMinY()
|| e.getBlock().getLocation().getBlockZ() == (int)g.getBoundingBox().getMaxY()
|| e.getBlock().getLocation().getBlockX() == (int)g.getBoundingBox().getMaxX() - 1
|| e.getBlock().getLocation().getBlockZ() == (int)g.getBoundingBox().getMinZ()
|| e.getBlock().getLocation().getBlockZ() == (int)g.getBoundingBox().getMaxZ() - 1
) {
user.sendMessage("greenhouses.broken");
plugin.getManager().getMap().removeGreenhouse(g);