Skip to content

Commit

Permalink
dont do work for greenhouses that arent loaded by players, checks the…
Browse files Browse the repository at this point in the history
… min and max coords for being loaded (#40)
  • Loading branch information
PhanaticD authored and tastybento committed Jan 13, 2020
1 parent 6f77d47 commit 01b607e
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,29 @@ private void setup() {
}

private void convertBlocks(Greenhouse gh) {
if(!gh.getLocation().getWorld().isChunkLoaded(((int) gh.getBoundingBox().getMaxX()) >> 4, ((int) gh.getBoundingBox().getMaxZ()) >> 4) || !gh.getLocation().getWorld().isChunkLoaded(((int) gh.getBoundingBox().getMinX()) >> 4, ((int) gh.getBoundingBox().getMinZ()) >> 4)){
//addon.log("Skipping convertblock for unloaded greenhouse at " + gh.getLocation());
return;
}
getAvailableBlocks(gh).stream().map(b -> b.getRelative(BlockFace.DOWN)).forEach(gh.getBiomeRecipe()::convertBlock);
}

private void verify(Greenhouse gh) {
if(!gh.getLocation().getWorld().isChunkLoaded(((int) gh.getBoundingBox().getMaxX()) >> 4, ((int) gh.getBoundingBox().getMaxZ()) >> 4) || !gh.getLocation().getWorld().isChunkLoaded(((int) gh.getBoundingBox().getMinX()) >> 4, ((int) gh.getBoundingBox().getMinZ()) >> 4)){
//addon.log("Skipping verify for unloaded greenhouse at " + gh.getLocation());
return;
}
if (!gh.getBiomeRecipe().checkRecipe(gh).isEmpty()) {
addon.log("Greenhouse failed verification at " + gh.getLocation());
g.removeGreenhouse(gh);
}
}

private void addMobs(Greenhouse gh) {
if(!gh.getLocation().getWorld().isChunkLoaded(((int) gh.getBoundingBox().getMaxX()) >> 4, ((int) gh.getBoundingBox().getMaxZ()) >> 4) || !gh.getLocation().getWorld().isChunkLoaded(((int) gh.getBoundingBox().getMinX()) >> 4, ((int) gh.getBoundingBox().getMinZ()) >> 4)){
//addon.log("Skipping addmobs for unloaded greenhouse at " + gh.getLocation());
return;
}
if (gh.getBiomeRecipe().noMobs()) {
return;
}
Expand Down Expand Up @@ -127,6 +139,10 @@ private void addMobs(Greenhouse gh) {
* @param gh - greenhouse
*/
private void growPlants(Greenhouse gh) {
if(!gh.getLocation().getWorld().isChunkLoaded(((int) gh.getBoundingBox().getMaxX()) >> 4, ((int) gh.getBoundingBox().getMaxZ()) >> 4) || !gh.getLocation().getWorld().isChunkLoaded(((int) gh.getBoundingBox().getMinX()) >> 4, ((int) gh.getBoundingBox().getMinZ()) >> 4)){
//addon.log("Skipping growplants for unloaded greenhouse at " + gh.getLocation());
return;
}
int bonemeal = getBoneMeal(gh);
if (bonemeal > 0) {
// Get a list of all available blocks
Expand Down

0 comments on commit 01b607e

Please sign in to comment.