Compare commits

..

No commits in common. "3f4647b547de6dfd3ece900ee1331c35775336ff" and "7e4f0764e660338d3d42bbc1fdc1ed6663debc2e" have entirely different histories.

2 changed files with 42 additions and 41 deletions

View File

@ -241,39 +241,36 @@ public class EcoSystemManager {
for (double z = ibb.getMinZ(); z < ibb.getMaxZ(); z++) {
for (double y = ibb.getMaxY() - 1; y >= bb.getMinY(); y--) {
Block b = gh.getWorld().getBlockAt(NumberConversions.floor(x), NumberConversions.floor(y), NumberConversions.floor(z));
if (checkBlock(result, b, ignoreLiquid)) {
break;
// Check floor blocks
if (!ignoreLiquid) {
// Check ceiling blocks
if (b.isEmpty() && !b.getRelative(BlockFace.UP).isEmpty()) {
result.add(new GrowthBlock(b, false));
}
if (!b.isEmpty() && !Tag.LEAVES.isTagged(b.getType())
&& (b.getRelative(BlockFace.UP).isEmpty()
|| b.getRelative(BlockFace.UP).isPassable()
|| Tag.LEAVES.isTagged(b.getRelative(BlockFace.UP).getType())
)
) {
result.add(new GrowthBlock(b.getRelative(BlockFace.UP), true));
break;
}
} else {
if (!b.isEmpty() && !b.isLiquid() && b.getRelative(BlockFace.UP).isLiquid()) {
result.add(new GrowthBlock(b.getRelative(BlockFace.UP), true));
break;
}
}
}
}
}
return result;
}
private boolean checkBlock(List<GrowthBlock> result, Block b, boolean ignoreLiquid) {
// Check floor blocks
if (!ignoreLiquid) {
// Check ceiling blocks
if (b.isEmpty() && !b.getRelative(BlockFace.UP).isEmpty()) {
result.add(new GrowthBlock(b, false));
}
if (!b.isEmpty() && !Tag.LEAVES.isTagged(b.getType())
&& (b.getRelative(BlockFace.UP).isEmpty()
|| b.getRelative(BlockFace.UP).isPassable()
|| Tag.LEAVES.isTagged(b.getRelative(BlockFace.UP).getType())
)
) {
result.add(new GrowthBlock(b.getRelative(BlockFace.UP), true));
return true;
}
} else {
if (!b.isEmpty() && !b.isLiquid() && b.getRelative(BlockFace.UP).isLiquid()) {
result.add(new GrowthBlock(b.getRelative(BlockFace.UP), true));
return true;
}
}
return false;
}
private int getBoneMeal(Greenhouse gh) {
Hopper hopper = getHopper(gh);

View File

@ -33,7 +33,7 @@ public class GreenhouseFinder {
/**
* This is the count of the various items
*/
private CounterCheck counterCheck = new CounterCheck();
private CounterCheck cc = new CounterCheck();
private Roof roof;
static class CounterCheck {
@ -97,26 +97,30 @@ public class GreenhouseFinder {
*/
CompletableFuture<Set<GreenhouseResult>> checkGreenhouse(AsyncWorldCache cache, Roof roof, Walls walls) {
CompletableFuture<Set<GreenhouseResult>> r = new CompletableFuture<>();
Bukkit.getScheduler().runTaskAsynchronously(BentoBox.getInstance(), () -> checkGreenhouseAsync(r, cache, roof, walls));
Bukkit.getScheduler().runTaskAsynchronously(BentoBox.getInstance(), () -> checkGHAsync(r, cache, roof, walls));
return r;
}
private Set<GreenhouseResult> checkGreenhouseAsync(CompletableFuture<Set<GreenhouseResult>> r, AsyncWorldCache cache,
private Set<GreenhouseResult> checkGHAsync(CompletableFuture<Set<GreenhouseResult>> r, AsyncWorldCache cache,
Roof roof, Walls walls) {
counterCheck = new CounterCheck();
cc = new CounterCheck();
int y;
for (y = roof.getHeight(); y > walls.getFloor(); y--) {
wallBlockCount = 0;
for (int x = walls.getMinX(); x <= walls.getMaxX(); x++) {
for (int z = walls.getMinZ(); z <= walls.getMaxZ(); z++) {
checkBlock(counterCheck, cache.getBlockType(x,y,z), roof, walls, new Vector(x, y, z));
checkBlock(cc, cache.getBlockType(x,y,z), roof, walls, new Vector(x, y, z));
}
}
if (wallBlockCount == 0 && y < roof.getHeight()) {
// This is the floor
break;
} else if (counterCheck.otherBlock && otherBlockLayer < 0) {
otherBlockLayer = y;
} else {
if (cc.otherBlock) {
if (otherBlockLayer < 0) {
otherBlockLayer = y;
}
}
}
}
@ -248,28 +252,28 @@ public class GreenhouseFinder {
* @return the wallDoors
*/
int getWallDoors() {
return counterCheck.doorCount;
return cc.doorCount;
}
/**
* @return the ghHopper
*/
int getGhHopper() {
return counterCheck.hopperCount;
return cc.hopperCount;
}
/**
* @return the airHoles
*/
boolean isAirHoles() {
return counterCheck.airHole;
return cc.airHole;
}
/**
* @return the otherBlocks
*/
boolean isOtherBlocks() {
return counterCheck.otherBlock;
return cc.otherBlock;
}
/**
@ -322,21 +326,21 @@ public class GreenhouseFinder {
}
public void setGhHopper(int i) {
counterCheck.hopperCount = i;
cc.hopperCount = i;
}
public void setWallDoors(int i) {
counterCheck.doorCount = i;
cc.doorCount = i;
}
public void setAirHoles(boolean b) {
counterCheck.airHole = b;
cc.airHole = b;
}
public void setOtherBlocks(boolean b) {
counterCheck.otherBlock = b;
cc.otherBlock = b;
}