aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-18 03:20:22 +0200
committernea <nea@nea.moe>2023-05-18 03:20:22 +0200
commit1dd603ab1cc42a602f1d82595dd15789ef63d2a3 (patch)
tree1658e1d32849d69102ff1e1b4c856da8428ab82b /src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java
parent3ebe3e80b929b03ad0bcb0c76cec6b3285fe08bd (diff)
downloadfirmament-1dd603ab1cc42a602f1d82595dd15789ef63d2a3.tar.gz
firmament-1dd603ab1cc42a602f1d82595dd15789ef63d2a3.tar.bz2
firmament-1dd603ab1cc42a602f1d82595dd15789ef63d2a3.zip
Add slot locking
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java b/src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java
new file mode 100644
index 0000000..dc19786
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java
@@ -0,0 +1,25 @@
+package moe.nea.firmament.mixins;
+
+import moe.nea.firmament.events.IsSlotProtectedEvent;
+import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.screen.slot.Slot;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin(ClientPlayerEntity.class)
+public abstract class MixinClientPlayerEntity extends PlayerEntity {
+ public MixinClientPlayerEntity() {
+ super(null, null, 0, null);
+ }
+
+ @Inject(method = "dropSelectedItem", at = @At("HEAD"), cancellable = true)
+ public void onDropSelectedItem(boolean entireStack, CallbackInfoReturnable<Boolean> cir) {
+ Slot fakeSlot = new Slot(getInventory(), getInventory().selectedSlot, 0, 0);
+ if (IsSlotProtectedEvent.shouldBlockInteraction(fakeSlot)) {
+ cir.setReturnValue(false);
+ }
+ }
+}