[SPIGOT-6870] Stepping into a Tripwire doesn't trigger a PlayerInteractEvent Created: 26/Dec/21 Updated: 18/Jan/22 |
|
Status: | Open |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | New Feature | Priority: | Minor |
Reporter: | Thomas Marchand | Assignee: | Unassigned |
Resolution: | Unresolved | Votes: | 0 |
Labels: | Craftbukkit, bug, event, spigot | ||
Environment: |
Java 17 Spigot 1.18.1 built today with buildtools. This server is running CraftBukkit version 3378-Spigot-8965a50-0ba6b90 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) |
Version: | 1.18.1 |
Guidelines Read: | Yes |
Description |
When you step into a tripwire, this tripwire gets powered. This is a server-side event. I want to disable this mechanic (I am working on a plugin which allows to replace some strings variations to simulate new blocks via a resourcepack). According to CraftBukkit source code this should be feasible by disabling PlayerInteractEvent, but this event is not called. Here is a block created using this method (you can see powered:false at the right): If I step inside the block, it gets powered: Here is CraftBukkit code from buildtools (net.minecraft.world.level.block.BlockTripWire.java), see line 165: {{ // If all of the events are cancelled block the tripwire trigger, else allow}} https://www.toptal.com/developers/hastebin/akudumigol.kotlin Here is a minimal example:
@EventHandler public void tripwireEvent1(PlayerInteractEvent event) { event.setCancelled(true); Logs.logInfo("triggered 1"); } @EventHandler public void tripwireEvent2(EntityInteractEvent event) { event.setCancelled(true); Logs.logInfo("triggered 2"); } Those events are successfully registered (I see "triggered 1" when right clicking on a block for example), but strangely, they are not triggered when you step into a tripwire which prevents me from disabling this mechanism. |
Comments |
Comment by Thomas Marchand [ 02/Jan/22 ] |
Thank you md_5, that makes sense. Do you have a suggestion to disable this mechanism? Is it possible to modify spigot so that this event is also called when the string is not attached ? Would you recommend me to propose a patch to the users of the plugin? |
Comment by md_5 [ 02/Jan/22 ] |
The event only fires for tripwire which is attached to a complete circuit (two tripwire hooks). Yours is not (attached=false in your debug screenshot). |
Comment by Thomas Marchand [ 31/Dec/21 ] |
Any idea? |