Skip to content

Commit

Permalink
Improve canDragIntoSlot
Browse files Browse the repository at this point in the history
  • Loading branch information
sjcl committed Jul 9, 2023
1 parent 58dd53c commit c8ffd73
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.*;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.teamfruit.ezstorage2patch.IEZInventory;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Invoker;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

Expand All @@ -24,6 +26,13 @@ public abstract class MixinContainerStorageCore extends Container {
@Invoker(value = "rowCount", remap = false)
protected abstract int invokeRowCount();

private IInventory inventory;

@Inject(method = "<init>", at = @At(value = "TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
private void injectConstructor(EntityPlayer player, World world, int x, int y, int z, CallbackInfo ci, int startingY, int startingX, IInventory inventory) {
this.inventory = inventory;
}

@Inject(method = "slotClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/inventory/Container;slotClick(IILnet/minecraft/inventory/ClickType;Lnet/minecraft/entity/player/EntityPlayer;)Lnet/minecraft/item/ItemStack;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void injectSlotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player, CallbackInfoReturnable<ItemStack> cir, ItemStack val) {
if (slotId != -999) {
Expand Down Expand Up @@ -88,6 +97,6 @@ private void injectCustomSlotClick(int slotId, int clickedButton, int mode, Enti

@Override
public boolean canDragIntoSlot(@NotNull Slot slotIn) {
return !(slotIn.inventory instanceof InventoryBasic);
return !slotIn.inventory.equals(this.inventory);
}
}

0 comments on commit c8ffd73

Please sign in to comment.