From 7b7de42516a798c4ee2c4543410a9e1d8c35f98d Mon Sep 17 00:00:00 2001 From: Siphalor Date: Thu, 27 May 2021 12:06:14 +0200 Subject: [PATCH 1/4] Update to Fabric Networking v1 --- build.gradle | 2 +- .../de/siphalor/mousewheelie/client/inventory/ToolPicker.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index d3cba414..f58144b5 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ dependencies { 'fabric-item-api-v1': '1.0.0+16acbe5ba7', 'fabric-lifecycle-events-v1': '1.2.0+74cc3b20a7', 'fabric-key-binding-api-v1': '1.0.1+730711c6a7', - 'fabric-networking-v0': '0.1.10+e00ecb5fa7', + 'fabric-networking-api-v1': '1.0.3+e3c9d0627d', 'fabric-tag-extensions-v0': '1.0.1+35e08e33a7', 'fabric-tool-attribute-api-v1': '1.2.0+d21d4635a7', 'fabric-resource-loader-v0': '0.2.8+35e08e33a7' diff --git a/src/main/java/de/siphalor/mousewheelie/client/inventory/ToolPicker.java b/src/main/java/de/siphalor/mousewheelie/client/inventory/ToolPicker.java index 44a29dd0..8b6ffe1b 100644 --- a/src/main/java/de/siphalor/mousewheelie/client/inventory/ToolPicker.java +++ b/src/main/java/de/siphalor/mousewheelie/client/inventory/ToolPicker.java @@ -21,8 +21,8 @@ import de.siphalor.mousewheelie.client.MWClient; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.network.ClientSidePacketRegistry; import net.minecraft.block.BlockState; +import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.packet.c2s.play.PickFromInventoryC2SPacket; @@ -86,7 +86,7 @@ private boolean pick(int index) { lastToolPickSlot = index; if (index != -1 && index != inventory.selectedSlot) { PickFromInventoryC2SPacket packet = new PickFromInventoryC2SPacket(index); - ClientSidePacketRegistry.INSTANCE.sendToServer(packet); + MinecraftClient.getInstance().getNetworkHandler().sendPacket(packet); return true; } return false; From cc5b88fb139b7ee39a6a7b47eb94be048988475c Mon Sep 17 00:00:00 2001 From: Siphalor Date: Thu, 27 May 2021 12:23:42 +0200 Subject: [PATCH 2/4] Fix #110 (emptying an offhand slot always triggers the refill offhand swapping) --- .../mousewheelie/client/MWClient.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/siphalor/mousewheelie/client/MWClient.java b/src/main/java/de/siphalor/mousewheelie/client/MWClient.java index 0501cc4a..bc86913d 100644 --- a/src/main/java/de/siphalor/mousewheelie/client/MWClient.java +++ b/src/main/java/de/siphalor/mousewheelie/client/MWClient.java @@ -111,11 +111,25 @@ public static boolean performRefill() { Hand hand = refillHand; refillHand = null; if (MWConfig.refill.offHand && hand.equals(Hand.OFF_HAND)) { - InteractionManager.push(new InteractionManager.PacketEvent(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN), triggerType -> triggerType == InteractionManager.TriggerType.CONTAINER_SLOT_UPDATE && MWClient.lastUpdatedSlot == 45)); + // interaction only gets pushed softly so it can be removed if the refill was not successful + InteractionManager.interactionEventQueue.add( + new InteractionManager.PacketEvent( + new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN), + triggerType -> triggerType == InteractionManager.TriggerType.CONTAINER_SLOT_UPDATE && MWClient.lastUpdatedSlot == 45 + ) + ); } - SlotRefiller.refill(); - if (MWConfig.refill.offHand && hand.equals(Hand.OFF_HAND)) { - InteractionManager.push(new InteractionManager.PacketEvent(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN), triggerType -> triggerType == InteractionManager.TriggerType.CONTAINER_SLOT_UPDATE && MWClient.lastUpdatedSlot == 45)); + if (SlotRefiller.refill()) { + if (MWConfig.refill.offHand && hand.equals(Hand.OFF_HAND)) { + InteractionManager.push( + new InteractionManager.PacketEvent( + new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN), + triggerType -> triggerType == InteractionManager.TriggerType.CONTAINER_SLOT_UPDATE && MWClient.lastUpdatedSlot == 45 + ) + ); + } + } else { + InteractionManager.clear(); } return true; From ea059df3648e57d368a0cc1cd888e2f840f7bb05 Mon Sep 17 00:00:00 2001 From: Siphalor Date: Thu, 27 May 2021 12:26:00 +0200 Subject: [PATCH 3/4] Version 1.7.2 - Fixed emptying off hands triggering the refill even if no such items were in the inventory. This caused a swapping between main and off hand that from there on triggered every time the main tool was right clicked with. Thanks to The-Fireplace for providing a good way to reproduce this :) --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 0c63b669..a23360ea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ yarn_build=5:v2 loader_version=0.10.6+build.214 # Mod Properties mod_id=mousewheelie -mod_version=1.7.1 +mod_version=1.7.2 mod_release=release mod_mc_version_specifier=1.16.3+ mod_mc_versions=1.16.3;1.16.4;1.16.5 From 02ae4cc33a9ad50cbc24f5cf0547d34e9af974f2 Mon Sep 17 00:00:00 2001 From: Siphalor Date: Thu, 27 May 2021 11:52:43 +0200 Subject: [PATCH 4/4] Update to Minotaur 1.2.1 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index f58144b5..003a0b22 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'fabric-loom' version '0.7-SNAPSHOT' id 'maven-publish' id 'com.matthewprenger.cursegradle' version '1.4.0' - id 'com.modrinth.minotaur' version '1.1.0' + id 'com.modrinth.minotaur' version '1.2.1' id 'org.cadixdev.licenser' version '0.5.0' } @@ -219,7 +219,7 @@ if (project.hasProperty("siphalorModrinthApi")) { versionName = "[${project.mod_mc_version_specifier}] ${project.mod_version}" changelog = getProjectChangelog() uploadFile = remapJar - releaseType = project.mod_release + versionType = project.mod_release for (version in ((String) project.mod_mc_versions).split(";")) { addGameVersion(version) }