|
1 | 1 | package io.github.lounode.eventwrapper.fabric.mixin.eventposter.entity.player.playerinteractevent; |
2 | 2 |
|
| 3 | +import net.minecraft.network.protocol.game.ServerboundInteractPacket; |
3 | 4 | import net.minecraft.server.network.ServerGamePacketListenerImpl; |
4 | 5 | import net.minecraft.world.InteractionHand; |
5 | 6 | import net.minecraft.world.InteractionResult; |
| 7 | +import net.minecraft.world.entity.Entity; |
| 8 | +import net.minecraft.world.entity.player.Player; |
6 | 9 | import net.minecraft.world.phys.Vec3; |
7 | 10 |
|
| 11 | +import org.spongepowered.asm.mixin.Final; |
8 | 12 | import org.spongepowered.asm.mixin.Mixin; |
9 | 13 | import org.spongepowered.asm.mixin.Shadow; |
10 | 14 | import org.spongepowered.asm.mixin.injection.At; |
|
15 | 19 | import io.github.lounode.eventwrapper.fabric.EventWrapperHooks; |
16 | 20 |
|
17 | 21 | @Mixin(targets = "net.minecraft.server.network.ServerGamePacketListenerImpl$1") |
18 | | -public abstract class PlayerInteractEventEntityInteractSpecificEventPoster { |
| 22 | +public abstract class PlayerInteractEventEntityInteractSpecificEventPoster implements ServerboundInteractPacket.Handler { |
19 | 23 |
|
20 | 24 | @Shadow |
21 | | - protected abstract void performInteraction(InteractionHand hand, ServerGamePacketListenerImpl.EntityInteraction interaction); |
| 25 | + @Final |
| 26 | + private ServerGamePacketListenerImpl field_28963; |
| 27 | + |
| 28 | + @Shadow |
| 29 | + @Final |
| 30 | + private Entity val$target; |
22 | 31 |
|
23 | 32 | @Inject( |
24 | 33 | method = "onInteraction(Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/Vec3;)V", |
25 | 34 | at = @At(value = "HEAD"), |
26 | 35 | cancellable = true |
27 | 36 | ) |
28 | 37 | private void onInteract(InteractionHand hand, Vec3 interactionLocation, CallbackInfo ci) { |
29 | | - ci.cancel(); |
30 | | - this.performInteraction(hand, ((serverPlayer, entity, interactionHand) -> { |
31 | | - InteractionResult result = EventWrapperHooks.onInteractEntityAt(serverPlayer, entity, interactionLocation, interactionHand); |
32 | | - if (result != null) { |
33 | | - return result; |
34 | | - } |
35 | | - return entity.interactAt(serverPlayer, interactionLocation, interactionHand); |
36 | | - })); |
| 38 | + Player player = this.field_28963.getPlayer(); |
| 39 | + |
| 40 | + InteractionResult result = EventWrapperHooks.onInteractEntityAt(player, this.val$target, interactionLocation, hand); |
| 41 | + |
| 42 | + if (result != null) { |
| 43 | + ci.cancel(); |
| 44 | + } |
37 | 45 | } |
38 | 46 | } |
0 commit comments