aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/moe/nea/firmament')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java3
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java13
2 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java b/src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java
index 21e3308..16e8fc3 100644
--- a/src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java
+++ b/src/main/java/moe/nea/firmament/mixins/MixinClientPlayerEntity.java
@@ -10,6 +10,7 @@ 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 net.minecraft.screen.slot.SlotActionType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -24,7 +25,7 @@ public abstract class MixinClientPlayerEntity extends PlayerEntity {
@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)) {
+ if (IsSlotProtectedEvent.shouldBlockInteraction(fakeSlot, SlotActionType.THROW)) {
cir.setReturnValue(false);
}
}
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java
index 84c47cb..3972ffc 100644
--- a/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java
+++ b/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java
@@ -10,6 +10,7 @@ import moe.nea.firmament.events.*;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.entity.player.PlayerInventory;
+import net.minecraft.item.ItemStack;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
@@ -63,11 +64,19 @@ public abstract class MixinHandledScreen<T extends ScreenHandler> {
@Inject(method = "onMouseClick(Lnet/minecraft/screen/slot/Slot;IILnet/minecraft/screen/slot/SlotActionType;)V", at = @At("HEAD"), cancellable = true)
public void onMouseClickedSlot(Slot slot, int slotId, int button, SlotActionType actionType, CallbackInfo ci) {
- if (IsSlotProtectedEvent.shouldBlockInteraction(slot)) {
+ if (slotId == -999 && getScreenHandler() != null && actionType == SlotActionType.PICKUP) { // -999 is code for "clicked outside the main window"
+ ItemStack cursorStack = getScreenHandler().getCursorStack();
+ if (cursorStack != null && IsSlotProtectedEvent.shouldBlockInteraction(slot, SlotActionType.THROW, cursorStack)) {
+ ci.cancel();
+ return;
+ }
+ }
+ if (IsSlotProtectedEvent.shouldBlockInteraction(slot, actionType)) {
ci.cancel();
+ return;
}
if (actionType == SlotActionType.SWAP && 0 <= button && button < 9) {
- if (IsSlotProtectedEvent.shouldBlockInteraction(new Slot(playerInventory, button, 0, 0))) {
+ if (IsSlotProtectedEvent.shouldBlockInteraction(new Slot(playerInventory, button, 0, 0), actionType)) {
ci.cancel();
}
}