Skip to content

Commit

Permalink
尝试修复 #15
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 committed May 20, 2023
1 parent bc5f17c commit e9f73c8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<BlockPosition, Integer> POWER_MAP = new HashMap<>();
Expand Down Expand Up @@ -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<ItemStack> drops) {
Expand Down Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/dev/sefiraat/netheopoiesis/api/items/NetherSeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<BlockFace> BREEDING_DIRECTIONS = Set.of(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -324,6 +331,7 @@ && getPlacements().contains(crux.getId())
}
// Wasn't placable, so cancel the event
event.setCancelled(true);
Slimefun.getDatabaseManager().getBlockDataController().removeBlock(location);
}

/**
Expand Down

0 comments on commit e9f73c8

Please sign in to comment.