Skip to content

Commit

Permalink
Fix a bug breaking middle-click drag in creative mode
Browse files Browse the repository at this point in the history
  • Loading branch information
NotRyken committed Sep 5, 2024
1 parent 6054c14 commit ea04d2a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Add Simplified Chinese translation (SnowCutieOwO)
- Fix a bug breaking middle-click drag in creative mode
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ClickType;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -63,6 +64,9 @@ protected MixinAbstractContainerScreen(Component textComponent_1) {
@Shadow
protected Slot hoveredSlot;

@Shadow
private ItemStack draggingItem;

@Inject(
method = "mouseClicked",
at = @At(value = "HEAD"),
Expand Down Expand Up @@ -135,10 +139,13 @@ public boolean mouseWheelie_triggerSort() {
@Unique
private boolean clientSort$specialOperation(int button) {
Options options = this.minecraft.options;
if (this.hoveredSlot.hasItem() &&
((options.keyPickItem.matchesMouse(button)
&& this.minecraft.gameMode.hasInfiniteItems())
|| options.keyDrop.matchesMouse(button))) {
if (((options.keyPickItem.matchesMouse(button)
&& this.minecraft.gameMode.hasInfiniteItems()
&& (this.hoveredSlot.hasItem()
|| !this.draggingItem.isEmpty()
|| !this.menu.getCarried().isEmpty())))
|| (options.keyDrop.matchesMouse(button)
&& this.hoveredSlot.hasItem())) {
return true;
}
else if (options.keySwapOffhand.matchesMouse(button)) {
Expand All @@ -158,10 +165,13 @@ else if (options.keySwapOffhand.matchesMouse(button)) {
@Unique
private boolean clientSort$specialOperation(int keyCode, int scanCode) {
Options options = this.minecraft.options;
if (this.hoveredSlot.hasItem() &&
((options.keyPickItem.matches(keyCode, scanCode)
&& this.minecraft.gameMode.hasInfiniteItems())
|| options.keyDrop.matches(keyCode, scanCode))) {
if (((options.keyPickItem.matches(keyCode, scanCode)
&& this.minecraft.gameMode.hasInfiniteItems()
&& (this.hoveredSlot.hasItem()
|| !this.draggingItem.isEmpty()
|| !this.menu.getCarried().isEmpty())))
|| (options.keyDrop.matches(keyCode, scanCode)
&& this.hoveredSlot.hasItem())) {
return true;
}
else if (options.keySwapOffhand.matches(keyCode, scanCode)) {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Neo/Forge version ranges: https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html

# Project
mod_version=0.8.0
mod_version=0.9.0
mod_group=dev.terminalmc
mod_id=clientsort
mod_name=ClientSort
Expand Down Expand Up @@ -65,12 +65,12 @@ curseforge_id=1049891
release_type=beta
# Fabric
release_mod_loaders_fabric=fabric,quilt
release_game_versions_fabric=1.21
release_game_versions_fabric=1.21,1.21.1
release_required_dep_ids_fabric_mr=P7dR8mSH,mOgUt4GM,9s6osm5g
release_required_dep_ids_fabric_cf=fabric-api,modmenu,cloth-config
# NeoForge
release_mod_loaders_neoforge=neoforge
release_game_versions_neoforge=1.21
release_game_versions_neoforge=1.21,1.21.1
release_required_dep_ids_neoforge_mr=9s6osm5g
release_required_dep_ids_neoforge_cf=cloth-config

Expand Down

0 comments on commit ea04d2a

Please sign in to comment.