SpongeForge icon indicating copy to clipboard operation
SpongeForge copied to clipboard

Block interaction events processed incorrectly

Open PolyacovYury opened this issue 4 years ago • 0 comments

I am currently running

  • SpongeForge version: 1.12.2-2838-7.2.4-RC4072

  • Relevant Plugins/Mods:

    • Quark 1.12.2-r1.6-180
    • GriefDefender Sponge 1.12.2-1.5.2

Issue Description Copy-pasting some Discord dicussion of this below. Sorry if a bit long, but it all contains necessary information.

Polyacov_Yury

not sure if this is a Sponge or GD issue
I have Quark. if there is a double door - players are able to open one of them.

// DoubleDoors.java
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) {
    if(event.getEntityPlayer().isSneaking() || event.isCanceled() || event.getResult() == Result.DENY || event.getUseBlock() == Result.DENY)
        return;

from this I can only deduce that the event isn't actually canceled or denied?
https://griefdefender.github.io/debug/?ApJgEdvL5W

kencinder

Sure it's not just visual? Even vanilla doors sometimes look like you've opened them, but they're still closed on the server and you can't go through

Polyacov_Yury

No, it isn't visual, the second door actually updates. It stays open after relog and allows players to walk through - unlike the case when it only opens client-side, in which case you can try to walk through but get pushed back by the server

kencinder

I'd bet on quark not firing event for both doors if one is opened
One actually interacted with gets cancelled...other doesn't

Polyacov_Yury

It checks if one got opened and updates the other if that's the case. I provided a code snippet which shows that

bloodshot

Bug in sponge
https://github.com/SpongePowered/SpongeCommon/blob/stable-7/src/main/java/org/spongepowered/common/mixin/core/server/management/PlayerInteractionManagerMixin.java#L275
should also check if block use result is false
https://github.com/SpongePowered/SpongeCommon/blob/stable-7/src/main/java/org/spongepowered/common/mixin/core/server/management/PlayerInteractionManagerMixin.java#L282-L289 This won't be called if not
getUseBlockResult
actually
you still need to run the item logic in this case
plugins can stop block usage and not cancel event
GD does this to allow item usage to run
https://github.com/SpongePowered/SpongeCommon/blob/stable-7/src/main/java/org/spongepowered/common/mixin/core/server/management/PlayerInteractionManagerMixin.java#L276-L298
this should run if event is cancelled or block use is false
actually
https://github.com/SpongePowered/SpongeCommon/blob/stable-7/src/main/java/org/spongepowered/common/mixin/core/server/management/PlayerInteractionManagerMixin.java#L282-L289
the code after is for placement

Polyacov_Yury

May I humbly ask you to make a fix for sponge yourself?)

bloodshot

im not going down that road
create a ticket and gabizou will fix it
the issue is in that code
https://github.com/SpongePowered/SpongeCommon/blob/stable-7/src/main/java/org/spongepowered/common/mixin/core/server/management/PlayerInteractionManagerMixin.java#L278-L289 Needs to run if getBlockUseResult is false
This too https://github.com/SpongePowered/SpongeCommon/blob/stable-7/src/main/java/org/spongepowered/common/mixin/core/server/management/PlayerInteractionManagerMixin.java#L298

PolyacovYury avatar Nov 01 '20 07:11 PolyacovYury