diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9cf60c..c771fd5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,10 +14,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 16 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 16 + java-version: 17 - name: Cache SonarCloud packages uses: actions/cache@v1 with: diff --git a/.gitignore b/.gitignore index 525681c..03804dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ /target/ /.classpath /.project +/.DS_Store +/Greenhouses-addon.iml +/.idea/ diff --git a/pom.xml b/pom.xml index 31147e7..49c2e8c 100644 --- a/pom.xml +++ b/pom.xml @@ -43,11 +43,11 @@ UTF-8 UTF-8 - 16 + 17 2.0.9 - 1.18.1-R0.1-SNAPSHOT - 1.18.1 + 1.19.3-R0.1-SNAPSHOT + 1.21.0 ${build.version}-SNAPSHOT diff --git a/src/main/java/world/bentobox/greenhouses/greenhouse/BiomeRecipe.java b/src/main/java/world/bentobox/greenhouses/greenhouse/BiomeRecipe.java index f51f67a..b44ae5d 100644 --- a/src/main/java/world/bentobox/greenhouses/greenhouse/BiomeRecipe.java +++ b/src/main/java/world/bentobox/greenhouses/greenhouse/BiomeRecipe.java @@ -2,6 +2,7 @@ package world.bentobox.greenhouses.greenhouse; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.EnumMap; import java.util.HashSet; import java.util.List; @@ -24,6 +25,8 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.data.Bisected; import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.block.data.type.GlowLichen; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Hoglin; @@ -34,6 +37,7 @@ import com.google.common.base.Enums; 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; @@ -60,12 +64,26 @@ public class BiomeRecipe implements Comparable { } private static final List ADJ_BLOCKS = Arrays.asList( BlockFace.DOWN, BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.UP, BlockFace.WEST); + private static final List UNDERWATER_PLANTS; + static { + List m = new ArrayList<>(); + Arrays.stream(Material.values()).filter(c -> c.name().contains("CORAL")).forEach(m::add); + m.add(Material.SEA_LANTERN); + m.add(Material.SEA_PICKLE); + m.add(Material.SEAGRASS); + m.add(Material.KELP); + m.add(Material.GLOW_LICHEN); + UNDERWATER_PLANTS = Collections.unmodifiableList(m); + } // Content requirements // Material, Type, Qty. There can be more than one type of material required private final Map requiredBlocks = new EnumMap<>(Material.class); - // Plants + /** + * Tree map of plants + */ private final TreeMap plantTree = new TreeMap<>(); + private final TreeMap underwaterPlants = new TreeMap<>(); // Mobs // Entity Type, Material to Spawn on, Probability @@ -148,11 +166,12 @@ public class BiomeRecipe implements Comparable { */ public boolean addPlants(Material plantMaterial, double plantProbability, Material plantGrowOn) { double probability = plantProbability/100; + TreeMap map = UNDERWATER_PLANTS.contains(plantMaterial) ? underwaterPlants : plantTree; // Add up all the probabilities in the list so far - double lastProb = plantTree.isEmpty() ? 0D : plantTree.lastKey(); + double lastProb = map.isEmpty() ? 0D : map.lastKey(); if ((1D - lastProb) >= probability) { // Add to probability tree - plantTree.put(lastProb + probability, new GreenhousePlant(plantMaterial, plantGrowOn)); + map.put(lastProb + probability, new GreenhousePlant(plantMaterial, plantGrowOn)); } else { addon.logError("Plant chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + plantMaterial.toString()); return false; @@ -357,7 +376,9 @@ public class BiomeRecipe implements Comparable { Location spawnLoc = b.getLocation().clone().add(new Vector(0.5, 0, 0.5)); return 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)) + .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 -> { Entity entity = b.getWorld().spawnEntity(spawnLoc, m.mobType()); @@ -408,11 +429,11 @@ public class BiomeRecipe implements Comparable { return key == null ? Optional.empty() : Optional.ofNullable(mobTree.get(key)); } - private Optional getRandomPlant() { + private Optional getRandomPlant(boolean underwater) { // Grow a random plant that can grow double r = random.nextDouble(); - Double key = plantTree.ceilingKey(r); - return key == null ? Optional.empty() : Optional.ofNullable(plantTree.get(key)); + Double key = underwater ? underwaterPlants.ceilingKey(r) : plantTree.ceilingKey(r); + return key == null ? Optional.empty() : Optional.ofNullable(underwater ? underwaterPlants.get(key) : plantTree.get(key)); } /** @@ -432,28 +453,34 @@ public class BiomeRecipe implements Comparable { /** * Plants a plant on block bl if it makes sense. * @param block - block that can have growth + * @param underwater - if the block is underwater or not * @return true if successful */ - public boolean growPlant(GrowthBlock block) { + public boolean growPlant(GrowthBlock block, boolean underwater) { Block bl = block.block(); - if (!bl.isEmpty()) { - return false; - } - return getRandomPlant().map(p -> { + return getRandomPlant(underwater).map(p -> { if (bl.getY() != 0 && canGrowOn(block, p)) { - if (!isBisected(bl, p)) { - return false; + if (plantIt(bl, p)) { + bl.getWorld().spawnParticle(Particle.SNOWBALL, bl.getLocation(), 10, 2, 2, 2); + return true; } - bl.getWorld().spawnParticle(Particle.SNOWBALL, bl.getLocation(), 10, 2, 2, 2); - return true; } return false; }).orElse(false); } - private boolean isBisected(Block bl, GreenhousePlant p) { + /** + * Plants the plant + * @param bl - block to turn into a plant + * @param p - the greenhouse plant to be grown + * @return true if successful, false if not + */ + private boolean plantIt(Block bl, GreenhousePlant p) { + boolean underwater = bl.getType().equals(Material.WATER); BlockData dataBottom = p.plantMaterial().createBlockData(); + // Check if this is a double-height plant if (dataBottom instanceof Bisected bi) { + // Double-height plant bi.setHalf(Bisected.Half.BOTTOM); BlockData dataTop = p.plantMaterial().createBlockData(); ((Bisected) dataTop).setHalf(Bisected.Half.TOP); @@ -463,18 +490,92 @@ public class BiomeRecipe implements Comparable { } else { return false; // No room } + } else if (p.plantMaterial().equals(Material.GLOW_LICHEN)) { + return placeLichen(bl); } else { - bl.setBlockData(dataBottom, false); + if (dataBottom instanceof Waterlogged wl) { + wl.setWaterlogged(underwater); + bl.setBlockData(wl, false); + } else { + // Single height plant + bl.setBlockData(dataBottom, false); + } } return true; } + /** + * Handles the placing of Glow Lichen. This needs to stick to a block rather than grow on it. + * If the block is set to Glow Lichen then it appears as an air block with 6 sides of lichen so + * they need to be switched off and only the side next to the block should be set. + * @param bl - block where plants would usually be placed + * @return true if successful, false if not + */ + private boolean placeLichen(Block bl) { + // Get the source block below this one + Block b = bl.getRelative(BlockFace.DOWN); + + // Find a spot for licen + BlockFace d = null; + boolean waterLogged = false; + for (BlockFace adj : ADJ_BLOCKS) { + if (b.getRelative(adj).getType().equals(Material.AIR)) { + d = adj; + break; + } + // Lichen can grow under water too + if (b.getRelative(adj).getType().equals(Material.WATER)) { + d = adj; + waterLogged = true; + break; + } + } + if (d == null) { + return false; + } + Block bb = b.getRelative(d); + bb.setType(Material.GLOW_LICHEN); + BlockFace opp = d.getOppositeFace(); + + if(bb.getBlockData() instanceof GlowLichen v){ + for (BlockFace f : v.getAllowedFaces()) { + v.setFace(f, false); + } + v.setFace(opp, true); + v.setWaterlogged(waterLogged); + bb.setBlockData(v); + bb.getState().setBlockData(v); + bb.getState().update(true); + return true; + } + return false; + } + + /** + * Checks if a particular plant can group at the location of a block + * @param block - block being checked + * @param p - greenhouse plant + * @return true if it can be grown otherwise false + */ private boolean canGrowOn(GrowthBlock block, GreenhousePlant p) { // Ceiling plants can only grow on ceiling blocks if (CEILING_PLANTS.contains(p.plantMaterial()) && Boolean.TRUE.equals(block.floor())) { return false; } - return p.plantGrownOn().equals(block.block().getRelative(Boolean.TRUE.equals(block.floor()) ? BlockFace.DOWN : BlockFace.UP).getType()); + // Underwater plants can only be placed in water and regular plants cannot be placed in water + if (block.block().getType().equals(Material.WATER)) { + BentoBox.getInstance().logDebug("Water block"); + if (!UNDERWATER_PLANTS.contains(p.plantMaterial())) { + return false; + } + BentoBox.getInstance().logDebug("Water plant"); + } else if (UNDERWATER_PLANTS.contains(p.plantMaterial())) { + return false; + } + + return p.plantGrownOn().equals(block.block().getRelative(Boolean.TRUE.equals(block.floor()) ? + BlockFace.DOWN : + BlockFace.UP).getType()); } /** diff --git a/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java b/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java index d371272..d4a0890 100644 --- a/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java +++ b/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java @@ -69,7 +69,7 @@ public class Walls extends MinMaxXZ { // The player is under the roof // Assume the player is inside the greenhouse they are trying to create final Location loc = roof.getLocation(); - floor = getFloorY(roof.getHeight(), roof.getMinX(), roof.getMaxX(), roof.getMinZ(), roof.getMaxZ()); + floor = getFloorY(roof.getHeight(), roof.getMinX(), roof.getMaxX(), roof.getMinZ(), roof.getMaxZ(), loc.getWorld().getMinHeight()); // Now start with the player's x and z location WallFinder wf = new WallFinder(); minX = loc.getBlockX(); @@ -85,7 +85,7 @@ public class Walls extends MinMaxXZ { minZ--; maxZ++; // Find the floor again, only looking within the walls - floor = getFloorY(roof.getHeight(), minX, maxX, minZ,maxZ); + floor = getFloorY(roof.getHeight(), minX, maxX, minZ,maxZ,loc.getWorld().getMinHeight()); // Complete on main thread Bukkit.getScheduler().runTask(BentoBox.getInstance(), () -> r.complete(this)); return this; @@ -159,7 +159,7 @@ public class Walls extends MinMaxXZ { } } - int getFloorY(int y, int minX, int maxX, int minZ, int maxZ) { + int getFloorY(int y, int minX, int maxX, int minZ, int maxZ, int minY) { // Find the floor - defined as the last y under the roof where there are no wall blocks int wallBlockCount; do { @@ -172,7 +172,7 @@ public class Walls extends MinMaxXZ { } } - } while( y-- > 0 && wallBlockCount > 0); + } while( y-- > minY && wallBlockCount > 0); return y + 1; } diff --git a/src/main/java/world/bentobox/greenhouses/managers/EcoSystemManager.java b/src/main/java/world/bentobox/greenhouses/managers/EcoSystemManager.java index d7ee49a..f8bd434 100644 --- a/src/main/java/world/bentobox/greenhouses/managers/EcoSystemManager.java +++ b/src/main/java/world/bentobox/greenhouses/managers/EcoSystemManager.java @@ -183,9 +183,13 @@ public class EcoSystemManager { int bonemeal = getBoneMeal(gh); if (bonemeal > 0) { // Get a list of all available blocks - List list = getAvailableBlocks(gh, true); + List list = getAvailableBlocks(gh, false); Collections.shuffle(list); - int plantsGrown = list.stream().limit(bonemeal).mapToInt(bl -> gh.getBiomeRecipe().growPlant(bl) ? 1 : 0).sum(); + int plantsGrown = list.stream().limit(bonemeal).mapToInt(bl -> gh.getBiomeRecipe().growPlant(bl, false) ? 1 : 0).sum(); + // Underwater plants + list = getAvailableBlocks(gh, true); + Collections.shuffle(list); + plantsGrown += list.stream().limit(bonemeal).mapToInt(bl -> gh.getBiomeRecipe().growPlant(bl, true) ? 1 : 0).sum(); if (plantsGrown > 0) { setBoneMeal(gh, bonemeal - (int)Math.ceil((double)plantsGrown / PLANTS_PER_BONEMEAL )); } @@ -208,6 +212,7 @@ public class EcoSystemManager { } + public record GrowthBlock(Block block, Boolean floor) {} /** * Get a list of the lowest level blocks inside the greenhouse. May be air, liquid or plants. @@ -225,26 +230,31 @@ 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)); - // Check ceiling blocks - if (b.isEmpty() && !b.getRelative(BlockFace.UP).isEmpty()) { - result.add(new GrowthBlock(b, false)); - } // Check floor blocks - if (!(b.isEmpty() || (ignoreLiquid && b.isLiquid())) - && (b.getRelative(BlockFace.UP).isEmpty() - || (b.getRelative(BlockFace.UP).isPassable() && !b.isLiquid()) - || (ignoreLiquid && b.isLiquid() && b.getRelative(BlockFace.UP).isPassable()))) { - result.add(new GrowthBlock(b.getRelative(BlockFace.UP), true)); - break; + if (!ignoreLiquid) { + // Check ceiling blocks + if (b.isEmpty() && !b.getRelative(BlockFace.UP).isEmpty()) { + result.add(new GrowthBlock(b, false)); + } + if (!b.isEmpty() && (b.getRelative(BlockFace.UP).isEmpty() || b.getRelative(BlockFace.UP).isPassable())) { + 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; } - public record GrowthBlock(Block block, Boolean floor) {} + private int getBoneMeal(Greenhouse gh) { Hopper hopper = getHopper(gh); diff --git a/src/main/java/world/bentobox/greenhouses/managers/GreenhouseManager.java b/src/main/java/world/bentobox/greenhouses/managers/GreenhouseManager.java index b540608..a18e569 100644 --- a/src/main/java/world/bentobox/greenhouses/managers/GreenhouseManager.java +++ b/src/main/java/world/bentobox/greenhouses/managers/GreenhouseManager.java @@ -96,29 +96,19 @@ public class GreenhouseManager implements Listener { handler.loadObjects().forEach(g -> { GreenhouseResult result = map.addGreenhouse(g); switch (result) { - case FAIL_NO_ISLAND: - // Delete the failed greenhouse - toBeRemoved.add(g); - break; - case FAIL_OVERLAPPING: - addon.logError("Greenhouse overlaps with another greenhouse. Skipping..."); - break; - case NULL: - addon.logError("Null location of greenhouse. Cannot load. Skipping..."); - break; - case SUCCESS: - activateGreenhouse(g); - break; - case FAIL_NO_WORLD: - addon.logError("Database contains greenhouse for a non-loaded world. Skipping..."); - break; - case FAIL_UNKNOWN_RECIPE: - addon.logError("Greenhouse uses a recipe that does not exist in the biomes.yml. Skipping..."); - addon.logError("Greenhouse Id " + g.getUniqueId()); - break; - default: - break; - + case FAIL_NO_ISLAND -> + // Delete the failed greenhouse + toBeRemoved.add(g); + case FAIL_OVERLAPPING -> addon.logError("Greenhouse overlaps with another greenhouse. Skipping..."); + case NULL -> addon.logError("Null location of greenhouse. Cannot load. Skipping..."); + case SUCCESS -> activateGreenhouse(g); + case FAIL_NO_WORLD -> addon.logError("Database contains greenhouse for a non-loaded world. Skipping..."); + case FAIL_UNKNOWN_RECIPE -> { + addon.logError("Greenhouse uses a recipe that does not exist in the biomes.yml. Skipping..."); + addon.logError("Greenhouse Id " + g.getUniqueId()); + } + default -> { + } } }); addon.log("Loaded " + map.getSize() + " greenhouses."); diff --git a/src/main/java/world/bentobox/greenhouses/managers/GreenhouseMap.java b/src/main/java/world/bentobox/greenhouses/managers/GreenhouseMap.java index 4801c1a..91d2af4 100644 --- a/src/main/java/world/bentobox/greenhouses/managers/GreenhouseMap.java +++ b/src/main/java/world/bentobox/greenhouses/managers/GreenhouseMap.java @@ -107,7 +107,9 @@ public class GreenhouseMap { private boolean isOverlapping(Greenhouse greenhouse) { return greenhouse.getLocation() != null && addon.getIslands().getIslandAt(greenhouse.getLocation()).map(i -> { greenhouses.putIfAbsent(i, new ArrayList<>()); - return greenhouses.get(i).stream().anyMatch(g -> g.getBoundingBox().overlaps(greenhouse.getBoundingBox())); + return greenhouses.get(i).stream().anyMatch(g -> + g.getLocation().getWorld().equals(greenhouse.getLocation().getWorld()) && + g.getBoundingBox().overlaps(greenhouse.getBoundingBox())); }).orElse(false); } diff --git a/src/main/java/world/bentobox/greenhouses/managers/RecipeManager.java b/src/main/java/world/bentobox/greenhouses/managers/RecipeManager.java index 7791648..248ba15 100644 --- a/src/main/java/world/bentobox/greenhouses/managers/RecipeManager.java +++ b/src/main/java/world/bentobox/greenhouses/managers/RecipeManager.java @@ -1,8 +1,14 @@ package world.bentobox.greenhouses.managers; import java.io.File; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; import java.util.Map.Entry; +import java.util.Objects; +import java.util.Optional; import java.util.stream.Collectors; import org.bukkit.ChatColor; diff --git a/src/main/resources/biomes.yml b/src/main/resources/biomes.yml index 343be9e..8f69223 100644 --- a/src/main/resources/biomes.yml +++ b/src/main/resources/biomes.yml @@ -285,3 +285,22 @@ biomes: mobs: SLIME: 5:WATER moblimit: 3 + DRIPSTONE_CAVES: + friendlyname: "&6Drippy Drops" + biome: dripstone_caves + icon: DRIPSTONE_BLOCK + priority: 15 + contents: + STONE: 8 + CLAY: 8 + # 50% water cove rage required + watercoverage: 25 + conversions: + CLAY: 50:DRIPSTONE_BLOCK:WATER + STONE: 0.005:COPPER_ORE:STONE + plants: + GLOW_LICHEN: 20:STONE + mobs: + skeleton: 5:STONE + glow_squid: 5:WATER + moblimit: 5 \ No newline at end of file diff --git a/src/test/java/world/bentobox/greenhouses/greenhouse/BiomeRecipeTest.java b/src/test/java/world/bentobox/greenhouses/greenhouse/BiomeRecipeTest.java index 8df65c1..db64690 100644 --- a/src/test/java/world/bentobox/greenhouses/greenhouse/BiomeRecipeTest.java +++ b/src/test/java/world/bentobox/greenhouses/greenhouse/BiomeRecipeTest.java @@ -611,7 +611,7 @@ public class BiomeRecipeTest { @Test public void testGrowPlantNotAir() { when(block.getType()).thenReturn(Material.SOUL_SAND); - assertFalse(br.growPlant(new GrowthBlock(block, true))); + assertFalse(br.growPlant(new GrowthBlock(block, true), false)); } /** @@ -621,7 +621,7 @@ public class BiomeRecipeTest { public void testGrowPlantNoPlants() { when(block.getType()).thenReturn(Material.AIR); when(block.isEmpty()).thenReturn(true); - assertFalse(br.growPlant(new GrowthBlock(block, true))); + assertFalse(br.growPlant(new GrowthBlock(block, true), false)); } /** @@ -633,7 +633,7 @@ public class BiomeRecipeTest { when(block.getType()).thenReturn(Material.AIR); when(block.isEmpty()).thenReturn(true); assertTrue(br.addPlants(Material.BAMBOO_SAPLING, 100, Material.GRASS_BLOCK)); - assertFalse(br.growPlant(new GrowthBlock(block, true))); + assertFalse(br.growPlant(new GrowthBlock(block, true), false)); } /** @@ -649,7 +649,7 @@ public class BiomeRecipeTest { when(block.getRelative(any())).thenReturn(ob); assertTrue(br.addPlants(Material.BAMBOO_SAPLING, 100, Material.GRASS_BLOCK)); - assertTrue(br.growPlant(new GrowthBlock(block, true))); + assertTrue(br.growPlant(new GrowthBlock(block, true), false)); verify(world).spawnParticle(eq(Particle.SNOWBALL), any(Location.class), anyInt(), anyDouble(), anyDouble(), anyDouble()); verify(block).setBlockData(eq(bd), eq(false)); } @@ -667,7 +667,7 @@ public class BiomeRecipeTest { when(block.getRelative(any())).thenReturn(ob); assertTrue(br.addPlants(Material.SPORE_BLOSSOM, 100, Material.GLASS)); - assertTrue(br.growPlant(new GrowthBlock(block, false))); + assertTrue(br.growPlant(new GrowthBlock(block, false), false)); verify(world).spawnParticle(eq(Particle.SNOWBALL), any(Location.class), anyInt(), anyDouble(), anyDouble(), anyDouble()); verify(block).setBlockData(eq(bd), eq(false)); } @@ -686,7 +686,7 @@ public class BiomeRecipeTest { when(block.getRelative(any())).thenReturn(ob); assertTrue(br.addPlants(Material.SPORE_BLOSSOM, 100, Material.GLASS)); // Not a ceiling block - assertFalse(br.growPlant(new GrowthBlock(block, true))); + assertFalse(br.growPlant(new GrowthBlock(block, true), false)); } /** @@ -704,7 +704,7 @@ public class BiomeRecipeTest { when(block.getRelative(BlockFace.DOWN)).thenReturn(ob); when(block.getRelative(BlockFace.UP)).thenReturn(block); assertTrue(br.addPlants(Material.SUNFLOWER, 100, Material.GRASS_BLOCK)); - assertTrue(br.growPlant(new GrowthBlock(block, true))); + assertTrue(br.growPlant(new GrowthBlock(block, true), false)); verify(world).spawnParticle(eq(Particle.SNOWBALL), any(Location.class), anyInt(), anyDouble(), anyDouble(), anyDouble()); verify(bisected).setHalf(eq(Half.BOTTOM)); verify(bisected).setHalf(eq(Half.TOP)); @@ -725,7 +725,7 @@ public class BiomeRecipeTest { when(block.getRelative(eq(BlockFace.DOWN))).thenReturn(ob); when(block.getRelative(eq(BlockFace.UP))).thenReturn(ob); assertTrue(br.addPlants(Material.SUNFLOWER, 100, Material.GRASS_BLOCK)); - assertFalse(br.growPlant(new GrowthBlock(block, true))); + assertFalse(br.growPlant(new GrowthBlock(block, true), false)); } /** diff --git a/src/test/java/world/bentobox/greenhouses/greenhouse/WallsTest.java b/src/test/java/world/bentobox/greenhouses/greenhouse/WallsTest.java index 29821e1..7231f34 100644 --- a/src/test/java/world/bentobox/greenhouses/greenhouse/WallsTest.java +++ b/src/test/java/world/bentobox/greenhouses/greenhouse/WallsTest.java @@ -177,15 +177,15 @@ public class WallsTest { } /** - * Test method for {@link world.bentobox.greenhouses.greenhouse.Walls#getFloorY(int, int, int, int, int)}. + * Test method for {@link world.bentobox.greenhouses.greenhouse.Walls#getFloorY(int, int, int, int, int, int)}. */ @Test public void testGetFloorYZeroY() { - assertEquals(0, walls.getFloorY(10, 0, 1, 0, 1)); + assertEquals(-64, walls.getFloorY(10, 0, 1, 0, 1, -64)); } /** - * Test method for {@link world.bentobox.greenhouses.greenhouse.Walls#getFloorY(int, int, int, int, int)}. + * Test method for {@link world.bentobox.greenhouses.greenhouse.Walls#getFloorY(int, int, int, int, int, int)}. */ @Test public void testGetFloorY() { @@ -193,7 +193,7 @@ public class WallsTest { Material.GLASS, Material.GLASS, Material.GLASS, Material.GLASS, Material.AIR); - assertEquals(8, walls.getFloorY(10, 0, 1, 0, 1)); + assertEquals(8, walls.getFloorY(10, 0, 1, 0, 1, -64)); } /** diff --git a/src/test/java/world/bentobox/greenhouses/managers/EcoSystemManagerTest.java b/src/test/java/world/bentobox/greenhouses/managers/EcoSystemManagerTest.java index 9364d72..6111923 100644 --- a/src/test/java/world/bentobox/greenhouses/managers/EcoSystemManagerTest.java +++ b/src/test/java/world/bentobox/greenhouses/managers/EcoSystemManagerTest.java @@ -123,6 +123,17 @@ public class EcoSystemManagerTest { when(liquid.getRelative(eq(BlockFace.UP))).thenReturn(liquid); when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(liquid); List result = eco.getAvailableBlocks(gh, false); + assertEquals(16, result.size()); + } + + /** + * Test method for {@link world.bentobox.greenhouses.managers.EcoSystemManager#getAvailableBlocks(Greenhouse, boolean)}. + */ + @Test + public void testGetAvailableBlocksAllLiquid2() { + when(liquid.getRelative(eq(BlockFace.UP))).thenReturn(liquid); + when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(liquid); + List result = eco.getAvailableBlocks(gh, true); assertEquals(0, result.size()); }