diff options
author | Anthony Hilyard <anthony.hilyard@gmail.com> | 2021-10-24 11:46:40 -0700 |
---|---|---|
committer | Anthony Hilyard <anthony.hilyard@gmail.com> | 2021-10-24 11:46:40 -0700 |
commit | ec4c5aebf3b5b5af872c6b168c02bedd2bd5a9e3 (patch) | |
tree | 7f46aca691a09d9df9140505403a647827011df6 /src/main/java/com/anthonyhilyard/iceberg/mixin/ItemEntityMixin.java | |
parent | 2b38fda32d059303bed929b7ae634efa4dffc706 (diff) | |
download | Iceberg-ec4c5aebf3b5b5af872c6b168c02bedd2bd5a9e3.tar.gz Iceberg-ec4c5aebf3b5b5af872c6b168c02bedd2bd5a9e3.tar.bz2 Iceberg-ec4c5aebf3b5b5af872c6b168c02bedd2bd5a9e3.zip |
Initial Fabric port.
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/mixin/ItemEntityMixin.java')
-rw-r--r-- | src/main/java/com/anthonyhilyard/iceberg/mixin/ItemEntityMixin.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/mixin/ItemEntityMixin.java b/src/main/java/com/anthonyhilyard/iceberg/mixin/ItemEntityMixin.java new file mode 100644 index 0000000..05540c9 --- /dev/null +++ b/src/main/java/com/anthonyhilyard/iceberg/mixin/ItemEntityMixin.java @@ -0,0 +1,28 @@ +package com.anthonyhilyard.iceberg.mixin; + +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.At.Shift; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.server.level.ServerPlayer; + +import com.anthonyhilyard.iceberg.network.IcebergNetworkProtocol; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ItemEntity.class) +public class ItemEntityMixin +{ + @Inject(method = { "playerTouch" }, + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;take(Lnet/minecraft/world/entity/Entity;I)V", ordinal = 0, shift = Shift.AFTER)) + private void onPlayerTouch(Player player, CallbackInfo info) + { + if (player instanceof ServerPlayer) + { + IcebergNetworkProtocol.sendItemPickupEvent((ServerPlayer)player, ((ItemEntity)(Object)this).getItem()); + } + } +} |