diff --git a/src/main/java/xyz/nucleoid/stimuli/StimuliInitializer.java b/src/main/java/xyz/nucleoid/stimuli/StimuliInitializer.java
index 0cedd84..821e02c 100644
--- a/src/main/java/xyz/nucleoid/stimuli/StimuliInitializer.java
+++ b/src/main/java/xyz/nucleoid/stimuli/StimuliInitializer.java
@@ -48,7 +48,7 @@ public void onInitialize() {
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
if (player instanceof ServerPlayerEntity serverPlayer) {
try (var invokers = Stimuli.select().forEntityAt(player, hitResult.getBlockPos())) {
- return invokers.get(BlockUseEvent.EVENT).onUse(serverPlayer, hand, hitResult);
+ return invokers.get(BlockUseEvent.INTERACT).onBlockInteraction(serverPlayer, hand, hitResult);
}
}
return ActionResult.PASS;
diff --git a/src/main/java/xyz/nucleoid/stimuli/event/block/BlockUseEvent.java b/src/main/java/xyz/nucleoid/stimuli/event/block/BlockUseEvent.java
index cd3554a..190e4cf 100644
--- a/src/main/java/xyz/nucleoid/stimuli/event/block/BlockUseEvent.java
+++ b/src/main/java/xyz/nucleoid/stimuli/event/block/BlockUseEvent.java
@@ -1,27 +1,35 @@
package xyz.nucleoid.stimuli.event.block;
+import net.minecraft.block.BlockState;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.ItemUsageContext;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.World;
import xyz.nucleoid.stimuli.event.StimulusEvent;
-/**
- * Called when a {@link ServerPlayerEntity} attempts to use a block by interacting.
- *
- *
Upon return:
- *
- * - {@link ActionResult#SUCCESS} cancels further processing and allows the use.
- *
- {@link ActionResult#FAIL} cancels further processing and cancels the use.
- *
- {@link ActionResult#PASS} moves on to the next listener.
- *
- * If all listeners return {@link ActionResult#PASS}, the use succeeds and proceeds with normal logic.
- */
-public interface BlockUseEvent {
- StimulusEvent EVENT = StimulusEvent.create(BlockUseEvent.class, ctx -> (player, hand, hitResult) -> {
+public final class BlockUseEvent {
+ /**
+ * Called when a {@link ServerPlayerEntity} attempts to interact with a block.
+ *
+ * This is before the game tries to use the block, or tries to use an item on the block.
+ *
+ *
Upon return:
+ *
+ * - {@link ActionResult#SUCCESS} cancels further processing and allows the use.
+ *
- {@link ActionResult#FAIL} cancels further processing and cancels the use.
+ *
- {@link ActionResult#PASS} moves on to the next listener.
+ *
+ * If all listeners return {@link ActionResult#PASS}, the use succeeds and proceeds with normal logic.
+ */
+ public static final StimulusEvent INTERACT = StimulusEvent.create(Interact.class, ctx -> (player, hand, hitResult) -> {
try {
for (var listener : ctx.getListeners()) {
- var result = listener.onUse(player, hand, hitResult);
+ var result = listener.onBlockInteraction(player, hand, hitResult);
if (result != ActionResult.PASS) {
return result;
}
@@ -32,5 +40,71 @@ public interface BlockUseEvent {
return ActionResult.PASS;
});
- ActionResult onUse(ServerPlayerEntity player, Hand hand, BlockHitResult hitResult);
+ /**
+ * Called when a {@link ServerPlayerEntity} attempts to use a block.
+ *
+ * Upon return:
+ *
+ * - {@link ActionResult#SUCCESS} cancels further processing and allows the use.
+ *
- {@link ActionResult#FAIL} cancels further processing and cancels the use.
+ *
- {@link ActionResult#PASS} moves on to the next listener.
+ *
+ * If all listeners return {@link ActionResult#PASS}, the use succeeds and proceeds with normal logic.
+ */
+ public static final StimulusEvent