Skip to content

Commit

Permalink
Remove debug
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Mar 26, 2023
1 parent 3740268 commit ac1d6e6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.util.Util;
import world.bentobox.greenhouses.Greenhouses;
import world.bentobox.greenhouses.data.Greenhouse;
Expand Down Expand Up @@ -377,36 +376,26 @@ public boolean spawnMob(Block b) {
}
// Center spawned mob
Location spawnLoc = b.getLocation().clone().add(new Vector(0.5, 0, 0.5));
BentoBox.getInstance().logDebug("Spawning at " + spawnLoc.getBlock().getType() + " " + spawnLoc);
getRandomMob().ifPresent(m -> {
BentoBox.getInstance().logDebug("Mob is " + m.mobType());
BentoBox.getInstance().logDebug("mobSpawnOn = " + m.mobSpawnOn());
BentoBox.getInstance().logDebug("Block below is " + b.getRelative(BlockFace.DOWN).getType());
});
boolean result = getRandomMob()
// Check if the spawn on block matches, if it exists
.filter(m -> Optional.of(m.mobSpawnOn())
.map(b.getRelative(BlockFace.DOWN).getType()::equals)
.orElse(true))
// If spawn occurs, check if it can fit inside greenhouse
.map(m -> {
BentoBox.getInstance().logDebug("Mob is " + m);
Entity entity = b.getWorld().spawnEntity(spawnLoc, m.mobType());
preventZombie(entity);
return addon
.getManager()
.getMap()
.getGreenhouse(b.getLocation()).map(gh -> {
BentoBox.getInstance().logDebug("Checking boundary");
if (!gh.getInternalBoundingBox().contains(entity.getBoundingBox())) {
entity.remove();
BentoBox.getInstance().logDebug("Removed");
return false;
}
return true;
}).orElse(false);
}).orElse(false);
BentoBox.getInstance().logDebug("Result = " + result);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.bukkit.util.BoundingBox;
import org.bukkit.util.NumberConversions;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.greenhouses.Greenhouses;
import world.bentobox.greenhouses.data.Greenhouse;
import world.bentobox.greenhouses.greenhouse.BiomeRecipe;
Expand Down Expand Up @@ -139,17 +138,14 @@ private void verify(Greenhouse gh) {
* @return true if mobs were spawned, false if not
*/
boolean addMobs(Greenhouse gh) {
BentoBox.getInstance().logDebug("Adding mobs");
final BoundingBox bb = gh.getBoundingBox();
if(gh.getLocation() == null || gh.getLocation().getWorld() == null || gh.getWorld() == null
|| !gh.getLocation().getWorld().isChunkLoaded(((int) bb.getMaxX()) >> 4, ((int) bb.getMaxZ()) >> 4)
|| !gh.getLocation().getWorld().isChunkLoaded(((int) bb.getMinX()) >> 4, ((int) bb.getMinZ()) >> 4)){
// Skipping addmobs for unloaded greenhouse
BentoBox.getInstance().logDebug("unloaded gh");
return false;
}
if (gh.getBiomeRecipe().noMobs()) {
BentoBox.getInstance().logDebug("No mobs in recipe");
return false;
}
// Check greenhouse chunks are loaded
Expand All @@ -158,7 +154,6 @@ boolean addMobs(Greenhouse gh) {
int chunkX = (int)(blockX / 16);
int chunkZ = (int)(blockZ / 16);
if (!gh.getWorld().isChunkLoaded(chunkX, chunkZ)) {
BentoBox.getInstance().logDebug("Chunks not loaded");
return false;
}
}
Expand All @@ -169,26 +164,19 @@ boolean addMobs(Greenhouse gh) {
.filter(e -> gh.contains(e.getLocation())).count();
// Get the blocks in the greenhouse where spawning could occur
List<GrowthBlock> list = new ArrayList<>(getAvailableBlocks(gh, false));
BentoBox.getInstance().logDebug("Entities = " + sum + " available blocks are " + list.size());
list.forEach(gb -> BentoBox.getInstance().logDebug(gb.block.getType()));
Collections.shuffle(list, new Random(System.currentTimeMillis()));
Iterator<GrowthBlock> it = list.iterator();
// Check if the greenhouse is full
if (sum >= gh.getBiomeRecipe().getMaxMob()) {
BentoBox.getInstance().logDebug("GH is full");
return false;
}
while (it.hasNext() && (sum == 0 || gh.getArea() / sum >= gh.getBiomeRecipe().getMobLimit())) {
// Spawn something if chance says so
if (gh.getBiomeRecipe().spawnMob(it.next().block())) {
// Add a mob to the sum in the greenhouse
BentoBox.getInstance().logDebug("Spawned a mob");
sum++;
}
}
if (sum == 0 ) {
BentoBox.getInstance().logDebug("Nothing spawned");
}
return sum > 0;
}

Expand Down

0 comments on commit ac1d6e6

Please sign in to comment.