diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/items/BeaconSiphoningBlock.java b/src/main/java/dev/sefiraat/netheopoiesis/api/items/BeaconSiphoningBlock.java index acef243..9a186a7 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/items/BeaconSiphoningBlock.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/items/BeaconSiphoningBlock.java @@ -4,7 +4,6 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import dev.sefiraat.netheopoiesis.Purification; -import dev.sefiraat.netheopoiesis.api.interfaces.CustomPlacementBlock; import dev.sefiraat.netheopoiesis.api.interfaces.PurificationDrain; import dev.sefiraat.netheopoiesis.listeners.CustomPlacementListener; import dev.sefiraat.netheopoiesis.utils.Keys; @@ -15,6 +14,8 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; @@ -40,7 +41,7 @@ * It will also post its location to the Registry and draw additional power from other SiphoningBlocks * below it so long as it's a tier higher. */ -public class BeaconSiphoningBlock extends SlimefunItem implements PurificationDrain, CustomPlacementBlock { +public class BeaconSiphoningBlock extends SlimefunItem implements PurificationDrain { @Nonnull private static final Map POWER_MAP = new HashMap<>(); @@ -88,6 +89,13 @@ public void uniqueTick() { onUniqueTick(); } }, + new BlockPlaceHandler(false) { + @Override + @ParametersAreNonnullByDefault + public void onPlayerPlace(BlockPlaceEvent e) { + whenPlaced(e); + } + }, new BlockBreakHandler(false, false) { @Override public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List drops) { @@ -164,6 +172,7 @@ public void whenPlaced(@Nonnull BlockPlaceEvent event) { } // Wasn't placable, so cancel the event event.setCancelled(true); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(location); } @Override diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherSeed.java b/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherSeed.java index 097b159..4afb1c1 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherSeed.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherSeed.java @@ -7,7 +7,6 @@ import dev.sefiraat.netheopoiesis.Registry; import dev.sefiraat.netheopoiesis.api.RecipeTypes; import dev.sefiraat.netheopoiesis.api.events.PlantBeforeGrowthEvent; -import dev.sefiraat.netheopoiesis.api.interfaces.CustomPlacementBlock; import dev.sefiraat.netheopoiesis.api.interfaces.NetherPlant; import dev.sefiraat.netheopoiesis.api.interfaces.SeedPaste; import dev.sefiraat.netheopoiesis.api.plant.Growth; @@ -34,6 +33,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.papermc.lib.PaperLib; @@ -70,7 +70,7 @@ /** * This class is used to define a Seed item that will grow as a {@link NetherPlant} */ -public abstract class NetherSeed extends SlimefunItem implements NetherPlant, SeedPaste, CustomPlacementBlock { +public abstract class NetherSeed extends SlimefunItem implements NetherPlant, SeedPaste { @Nonnull public static final Set BREEDING_DIRECTIONS = Set.of( @@ -132,6 +132,13 @@ public void tick(Block block, SlimefunItem item, SlimefunBlockData data) { } } }, + new BlockPlaceHandler(false) { + @Override + @ParametersAreNonnullByDefault + public void onPlayerPlace(BlockPlaceEvent e) { + whenPlaced(e); + } + }, new BlockBreakHandler(false, false) { @Override @ParametersAreNonnullByDefault @@ -324,6 +331,7 @@ && getPlacements().contains(crux.getId()) } // Wasn't placable, so cancel the event event.setCancelled(true); + Slimefun.getDatabaseManager().getBlockDataController().removeBlock(location); } /**