mirror of
https://github.com/BentoBoxWorld/Greenhouses.git
synced 2024-11-22 10:35:27 +01:00
Remove debug
This commit is contained in:
parent
3740268dfc
commit
ac1d6e6638
@ -38,7 +38,6 @@ import com.google.common.base.Enums;
|
|||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
import world.bentobox.greenhouses.Greenhouses;
|
import world.bentobox.greenhouses.Greenhouses;
|
||||||
import world.bentobox.greenhouses.data.Greenhouse;
|
import world.bentobox.greenhouses.data.Greenhouse;
|
||||||
@ -377,12 +376,6 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||||||
}
|
}
|
||||||
// Center spawned mob
|
// Center spawned mob
|
||||||
Location spawnLoc = b.getLocation().clone().add(new Vector(0.5, 0, 0.5));
|
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()
|
boolean result = getRandomMob()
|
||||||
// Check if the spawn on block matches, if it exists
|
// Check if the spawn on block matches, if it exists
|
||||||
.filter(m -> Optional.of(m.mobSpawnOn())
|
.filter(m -> Optional.of(m.mobSpawnOn())
|
||||||
@ -390,23 +383,19 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||||||
.orElse(true))
|
.orElse(true))
|
||||||
// If spawn occurs, check if it can fit inside greenhouse
|
// If spawn occurs, check if it can fit inside greenhouse
|
||||||
.map(m -> {
|
.map(m -> {
|
||||||
BentoBox.getInstance().logDebug("Mob is " + m);
|
|
||||||
Entity entity = b.getWorld().spawnEntity(spawnLoc, m.mobType());
|
Entity entity = b.getWorld().spawnEntity(spawnLoc, m.mobType());
|
||||||
preventZombie(entity);
|
preventZombie(entity);
|
||||||
return addon
|
return addon
|
||||||
.getManager()
|
.getManager()
|
||||||
.getMap()
|
.getMap()
|
||||||
.getGreenhouse(b.getLocation()).map(gh -> {
|
.getGreenhouse(b.getLocation()).map(gh -> {
|
||||||
BentoBox.getInstance().logDebug("Checking boundary");
|
|
||||||
if (!gh.getInternalBoundingBox().contains(entity.getBoundingBox())) {
|
if (!gh.getInternalBoundingBox().contains(entity.getBoundingBox())) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
BentoBox.getInstance().logDebug("Removed");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}).orElse(false);
|
}).orElse(false);
|
||||||
}).orElse(false);
|
}).orElse(false);
|
||||||
BentoBox.getInstance().logDebug("Result = " + result);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
import org.bukkit.util.BoundingBox;
|
import org.bukkit.util.BoundingBox;
|
||||||
import org.bukkit.util.NumberConversions;
|
import org.bukkit.util.NumberConversions;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
|
||||||
import world.bentobox.greenhouses.Greenhouses;
|
import world.bentobox.greenhouses.Greenhouses;
|
||||||
import world.bentobox.greenhouses.data.Greenhouse;
|
import world.bentobox.greenhouses.data.Greenhouse;
|
||||||
import world.bentobox.greenhouses.greenhouse.BiomeRecipe;
|
import world.bentobox.greenhouses.greenhouse.BiomeRecipe;
|
||||||
@ -139,17 +138,14 @@ public class EcoSystemManager {
|
|||||||
* @return true if mobs were spawned, false if not
|
* @return true if mobs were spawned, false if not
|
||||||
*/
|
*/
|
||||||
boolean addMobs(Greenhouse gh) {
|
boolean addMobs(Greenhouse gh) {
|
||||||
BentoBox.getInstance().logDebug("Adding mobs");
|
|
||||||
final BoundingBox bb = gh.getBoundingBox();
|
final BoundingBox bb = gh.getBoundingBox();
|
||||||
if(gh.getLocation() == null || gh.getLocation().getWorld() == null || gh.getWorld() == null
|
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.getMaxX()) >> 4, ((int) bb.getMaxZ()) >> 4)
|
||||||
|| !gh.getLocation().getWorld().isChunkLoaded(((int) bb.getMinX()) >> 4, ((int) bb.getMinZ()) >> 4)){
|
|| !gh.getLocation().getWorld().isChunkLoaded(((int) bb.getMinX()) >> 4, ((int) bb.getMinZ()) >> 4)){
|
||||||
// Skipping addmobs for unloaded greenhouse
|
// Skipping addmobs for unloaded greenhouse
|
||||||
BentoBox.getInstance().logDebug("unloaded gh");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (gh.getBiomeRecipe().noMobs()) {
|
if (gh.getBiomeRecipe().noMobs()) {
|
||||||
BentoBox.getInstance().logDebug("No mobs in recipe");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Check greenhouse chunks are loaded
|
// Check greenhouse chunks are loaded
|
||||||
@ -158,7 +154,6 @@ public class EcoSystemManager {
|
|||||||
int chunkX = (int)(blockX / 16);
|
int chunkX = (int)(blockX / 16);
|
||||||
int chunkZ = (int)(blockZ / 16);
|
int chunkZ = (int)(blockZ / 16);
|
||||||
if (!gh.getWorld().isChunkLoaded(chunkX, chunkZ)) {
|
if (!gh.getWorld().isChunkLoaded(chunkX, chunkZ)) {
|
||||||
BentoBox.getInstance().logDebug("Chunks not loaded");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,26 +164,19 @@ public class EcoSystemManager {
|
|||||||
.filter(e -> gh.contains(e.getLocation())).count();
|
.filter(e -> gh.contains(e.getLocation())).count();
|
||||||
// Get the blocks in the greenhouse where spawning could occur
|
// Get the blocks in the greenhouse where spawning could occur
|
||||||
List<GrowthBlock> list = new ArrayList<>(getAvailableBlocks(gh, false));
|
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()));
|
Collections.shuffle(list, new Random(System.currentTimeMillis()));
|
||||||
Iterator<GrowthBlock> it = list.iterator();
|
Iterator<GrowthBlock> it = list.iterator();
|
||||||
// Check if the greenhouse is full
|
// Check if the greenhouse is full
|
||||||
if (sum >= gh.getBiomeRecipe().getMaxMob()) {
|
if (sum >= gh.getBiomeRecipe().getMaxMob()) {
|
||||||
BentoBox.getInstance().logDebug("GH is full");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while (it.hasNext() && (sum == 0 || gh.getArea() / sum >= gh.getBiomeRecipe().getMobLimit())) {
|
while (it.hasNext() && (sum == 0 || gh.getArea() / sum >= gh.getBiomeRecipe().getMobLimit())) {
|
||||||
// Spawn something if chance says so
|
// Spawn something if chance says so
|
||||||
if (gh.getBiomeRecipe().spawnMob(it.next().block())) {
|
if (gh.getBiomeRecipe().spawnMob(it.next().block())) {
|
||||||
// Add a mob to the sum in the greenhouse
|
// Add a mob to the sum in the greenhouse
|
||||||
BentoBox.getInstance().logDebug("Spawned a mob");
|
|
||||||
sum++;
|
sum++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sum == 0 ) {
|
|
||||||
BentoBox.getInstance().logDebug("Nothing spawned");
|
|
||||||
}
|
|
||||||
return sum > 0;
|
return sum > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user