diff --git a/pom.xml b/pom.xml index 791b07c8..2294f343 100644 --- a/pom.xml +++ b/pom.xml @@ -135,5 +135,12 @@ 2.2.1 compile + + + com.github.DieReicheErethons + Brewery + 3.1 + provided + diff --git a/src/main/java/io/github/thebusybiscuit/exoticgarden/items/ExoticGardenFruit.java b/src/main/java/io/github/thebusybiscuit/exoticgarden/items/ExoticGardenFruit.java index 07e44d9b..0992788e 100644 --- a/src/main/java/io/github/thebusybiscuit/exoticgarden/items/ExoticGardenFruit.java +++ b/src/main/java/io/github/thebusybiscuit/exoticgarden/items/ExoticGardenFruit.java @@ -5,9 +5,12 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; +import com.dre.brewery.BCauldron; +import com.dre.brewery.utility.LegacyUtil; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -42,29 +45,30 @@ public boolean useVanillaBlockBreaking() { @Override public ItemUseHandler getItemHandler() { return e -> { - Optional block = e.getClickedBlock(); + Optional optionalBlock = e.getClickedBlock(); - if (block.isPresent()) { - Material material = block.get().getType(); + if (optionalBlock.isPresent()) { + Block block = optionalBlock.get(); // Cancel the Block placement if the Player sneaks or the Block is not interactable - if (e.getPlayer().isSneaking() || !isInteractable(material)) { + if (e.getPlayer().isSneaking() || !isInteractable(block)) { e.cancel(); } else { return; } - } - - if (edible && e.getPlayer().getFoodLevel() < 20) { - restoreHunger(e.getPlayer()); - ItemUtils.consumeItem(e.getItem(), false); + } else { + if (edible && e.getPlayer().getFoodLevel() < 20) { + restoreHunger(e.getPlayer()); + ItemUtils.consumeItem(e.getItem(), false); + } } }; } - private boolean isInteractable(@Nonnull Material material) { + private boolean isInteractable(@Nonnull Block block) { // We cannot rely on Material#isInteractable() sadly // as it would allow the placement of this block on strange items like stairs... + Material material = block.getType(); switch (material) { case ANVIL: case BREWING_STAND: @@ -73,11 +77,21 @@ private boolean isInteractable(@Nonnull Material material) { case HOPPER: case TRAPPED_CHEST: case ENDER_CHEST: - case CAULDRON: case SHULKER_BOX: return true; default: - return material.name().equals("BARREL") || material.name().endsWith("_SHULKER_BOX"); + return material.name().equals("BARREL") || + material.name().endsWith("_SHULKER_BOX") || + isBreweryCauldron(block); + } + } + + private boolean isBreweryCauldron(@Nonnull Block block) { + try { + return LegacyUtil.isWaterCauldron(block.getType()) && + LegacyUtil.isCauldronHeatsource(block.getRelative(BlockFace.DOWN)); + } catch (NoClassDefFoundError e) { + return false; } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 44598ce6..4f65d66c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -8,4 +8,7 @@ api-version: '1.13' main: io.github.thebusybiscuit.exoticgarden.ExoticGarden depend: -- Slimefun \ No newline at end of file +- Slimefun + +softdepend: +- Brewery \ No newline at end of file