Skip to content

Commit

Permalink
Prevent illegal slot transfers with scroll wheel which could cause du…
Browse files Browse the repository at this point in the history
…pes/non-vanilla behavior
  • Loading branch information
telvarost committed Jul 31, 2024
1 parent 015bf58 commit 2a7227c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=b1.7.3-build.2
loader_version=0.14.24-babric.1

# Mod Properties
mod_version=2.1.3
mod_version=2.1.4
maven_group=com.github.telvarost
archives_base_name=InventoryTweaks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import com.github.telvarost.inventorytweaks.Config;
import net.minecraft.client.gui.screen.ScreenBase;
import net.minecraft.client.gui.screen.container.ContainerBase;
import net.minecraft.container.Crafting;
import net.minecraft.container.Furnace;
import net.minecraft.entity.player.PlayerContainer;
import net.minecraft.item.ItemInstance;
import net.minecraft.container.slot.Slot;
import net.modificationstation.stationapi.api.network.ModdedPacketHandler;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -232,12 +234,29 @@ private void inventoryTweaks_mouseReleasedOrSlotChanged(int mouseX, int mouseY,
slotStackAmount = slotItemToExamine.count;
}

/** - Allow transfers if one or both of the slots are empty */
if ( (null != cursorStack)
&& (null != slotItemToExamine)
) {
/** - Prevent transfers if items in slots do not match */
transferAllowed = cursorStack.isDamageAndIDIdentical(slotItemToExamine);
}

/** - Prevent illegal transfers that can cause bugs/dupes */
if ( (slot.id == 0) && (container instanceof Crafting)
|| (slot.id == 2) && (container instanceof Furnace)
|| ( (container instanceof PlayerContainer)
&& ( (slot.id == 0)
|| (slot.id == 5)
|| (slot.id == 6)
|| (slot.id == 7)
|| (slot.id == 8)
)
)
) {
transferAllowed = false;
}

if (transferAllowed) {
inventoryTweaks_scrollCursorSlotTransfer(numberOfTurns, cursorStackAmount, slotStackAmount, itemBeingTransfered);
}
Expand Down

0 comments on commit 2a7227c

Please sign in to comment.