Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hand restock not working for water/lava/fish bucket(but works for power snow bucket). #524

Open
Sodium-Aluminate opened this issue Nov 6, 2024 · 3 comments

Comments

@Sodium-Aluminate
Copy link

Sodium-Aluminate commented Nov 6, 2024

checked #17, to avoid any network issue, using single player game

when I use the water bucket:
screenshot_before
screenshot_after

I found my hotbar was switch from slot 1 to slot 3, but the item 3 is empty bucket.

but if i try to put a stone, tweakeroo will only swap the item, and not switch my hotbar:
stone_before
stone_after

to avoid any other mod switch my hotbar, I turn onn the hand restock and tried again:
after_disable_restock
then my hotbar is still in the 1st slot.

I also tested by lava and fish bucket(fish buckets are copied by creative mode so the fish bucket have same nbt), also have this issue.
but the power snow buckets are working, it switched the hotbar but not swap the item:
powerSnow

@Sodium-Aluminate
Copy link
Author

I created a mixin to log the sendPacket function:

package fi.dy.masa.tweakeroo.mixin;

import net.minecraft.client.network.ClientCommonNetworkHandler;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.common.KeepAliveC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientCommonNetworkHandler.class)
public class SendPacketLogger {
    @Inject(method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"))
    private void a(Packet<?> packet, CallbackInfo ci){
        if(packet instanceof KeepAliveC2SPacket || packet instanceof PlayerMoveC2SPacket) return;
        System.out.println(packet.getClass());
    }
}

// here is what I found:
// using water bucket:
//[22:05:47] [Render thread/INFO] (Minecraft) [STDOUT]: class net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket
//[22:05:47] [Render thread/INFO] (Minecraft) [STDOUT]: class net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket
//[22:05:47] [Render thread/INFO] (Minecraft) [STDOUT]: class net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket 
// we can found that there are the 2nd Interact packet sent after the 1st swap packet
// which means we switch the hotbar first, then use the water bucket.
// so we should send switch hotbar packet it later.
//[22:05:47] [Render thread/INFO] (Minecraft) [STDOUT]: class net.minecraft.network.packet.c2s.play.HandSwingC2SPacket
//[22:05:47] [Render thread/INFO] (Minecraft) [STDOUT]: class net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket
//[22:05:53] [Render thread/INFO] (Minecraft) [STDOUT]: class net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket

// powersnow bucket, works fine.
//[22:06:05] [Render thread/INFO] (Minecraft) [STDOUT]: class net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket
//[22:06:05] [Render thread/INFO] (Minecraft) [STDOUT]: class net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket
//[22:06:05] [Render thread/INFO] (Minecraft) [STDOUT]: class net.minecraft.network.packet.c2s.play.HandSwingC2SPacket
//[22:06:05] [Render thread/INFO] (Minecraft) [STDOUT]: class net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket
//[22:06:09] [Render thread/INFO] (Minecraft) [STDOUT]: class net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket

@Sodium-Aluminate
Copy link
Author

the trace three packet:
PlayerInteractBlockC2SPacket -> UpdateSelectedSlotC2SPacket -> PlayerInteractItemC2SPacket

PlayerInteractBlockC2SPacket
java.lang.Exception
	at net.minecraft.client.network.ClientCommonNetworkHandler.printTrace(ClientCommonNetworkHandler.java:529)
	at net.minecraft.client.network.ClientCommonNetworkHandler.handler$zel000$tweakeroo$a(ClientCommonNetworkHandler.java:523)
	at net.minecraft.client.network.ClientCommonNetworkHandler.sendPacket(ClientCommonNetworkHandler.java)
	at net.minecraft.client.network.ClientPlayerInteractionManager.sendSequencedPacket(ClientPlayerInteractionManager.java:239)
	at net.minecraft.client.network.ClientPlayerInteractionManager.interactBlock(ClientPlayerInteractionManager.java:275)
	at fi.dy.masa.tweakeroo.tweaks.PlacementTweaks.processRightClickBlockWrapper(PlacementTweaks.java:816)
	at fi.dy.masa.tweakeroo.tweaks.PlacementTweaks.tryPlaceBlock(PlacementTweaks.java:602)
	at fi.dy.masa.tweakeroo.tweaks.PlacementTweaks.onProcessRightClickBlock(PlacementTweaks.java:365)
	at net.minecraft.client.MinecraftClient.redirect$zde000$tweakeroo$onProcessRightClickBlock(MinecraftClient.java:3007)
	at net.minecraft.client.MinecraftClient.doItemUse(MinecraftClient.java:1680)
	at net.minecraft.client.MinecraftClient.handleInputEvents(MinecraftClient.java:1907)
	at net.minecraft.client.MinecraftClient.tick(MinecraftClient.java:1758)
	at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1176)
	at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:838)
	at net.minecraft.client.main.Main.main(Main.java:237)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)
UpdateSelectedSlotC2SPacket
slot: 1
java.lang.Exception
	at net.minecraft.client.network.ClientCommonNetworkHandler.printTrace(ClientCommonNetworkHandler.java:529)
	at net.minecraft.client.network.ClientCommonNetworkHandler.handler$zel000$tweakeroo$a(ClientCommonNetworkHandler.java:521)
	at net.minecraft.client.network.ClientCommonNetworkHandler.sendPacket(ClientCommonNetworkHandler.java)
	at fi.dy.masa.tweakeroo.util.InventoryUtils.swapItemToHand(InventoryUtils.java:809)
	at fi.dy.masa.tweakeroo.util.InventoryUtils.restockNewStackToHand(InventoryUtils.java:331)
	at fi.dy.masa.tweakeroo.tweaks.PlacementTweaks.tryRestockHand(PlacementTweaks.java:693)
	at fi.dy.masa.tweakeroo.tweaks.PlacementTweaks.onProcessRightClickPost(PlacementTweaks.java:151)
	at net.minecraft.client.network.ClientPlayerInteractionManager.handler$zca000$tweakeroo$onProcessRightClickPost(ClientPlayerInteractionManager.java:587)
	at net.minecraft.client.network.ClientPlayerInteractionManager.method_41929(ClientPlayerInteractionManager.java:336)
	at net.minecraft.client.network.ClientPlayerInteractionManager.sendSequencedPacket(ClientPlayerInteractionManager.java:238)
	at net.minecraft.client.network.ClientPlayerInteractionManager.interactItem(ClientPlayerInteractionManager.java:323)
	at net.minecraft.client.MinecraftClient.doItemUse(MinecraftClient.java:1696)
	at net.minecraft.client.MinecraftClient.handleInputEvents(MinecraftClient.java:1907)
	at net.minecraft.client.MinecraftClient.tick(MinecraftClient.java:1758)
	at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1176)
	at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:838)
	at net.minecraft.client.main.Main.main(Main.java:237)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)
PlayerInteractItemC2SPacket
java.lang.Exception
	at net.minecraft.client.network.ClientCommonNetworkHandler.printTrace(ClientCommonNetworkHandler.java:529)
	at net.minecraft.client.network.ClientCommonNetworkHandler.handler$zel000$tweakeroo$a(ClientCommonNetworkHandler.java:523)
	at net.minecraft.client.network.ClientCommonNetworkHandler.sendPacket(ClientCommonNetworkHandler.java)
	at net.minecraft.client.network.ClientPlayerInteractionManager.sendSequencedPacket(ClientPlayerInteractionManager.java:239)
	at net.minecraft.client.network.ClientPlayerInteractionManager.interactItem(ClientPlayerInteractionManager.java:323)
	at net.minecraft.client.MinecraftClient.doItemUse(MinecraftClient.java:1696)
	at net.minecraft.client.MinecraftClient.handleInputEvents(MinecraftClient.java:1907)
	at net.minecraft.client.MinecraftClient.tick(MinecraftClient.java:1758)
	at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1176)
	at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:838)
	at net.minecraft.client.main.Main.main(Main.java:237)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)
HandSwingC2SPacket // not related
UpdateSelectedSlotC2SPacket
slot: 1
java.lang.Exception
	at net.minecraft.client.network.ClientCommonNetworkHandler.printTrace(ClientCommonNetworkHandler.java:529)
	at net.minecraft.client.network.ClientCommonNetworkHandler.handler$zel000$tweakeroo$a(ClientCommonNetworkHandler.java:521)
	at net.minecraft.client.network.ClientCommonNetworkHandler.sendPacket(ClientCommonNetworkHandler.java)
	at net.minecraft.client.network.ClientPlayerInteractionManager.syncSelectedSlot(ClientPlayerInteractionManager.java:265)
	at net.minecraft.client.network.ClientPlayerInteractionManager.tick(ClientPlayerInteractionManager.java:248)
	at net.minecraft.client.MinecraftClient.tick(MinecraftClient.java:1725)
	at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1176)
	at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:838)
	at net.minecraft.client.main.Main.main(Main.java:237)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)

we can found that: the UpdateSelectedSlotC2SPacket is sent by tweakeroo.tweaks.PlacementTweaks.onProcessRightClickPost,and caused by net.minecraft.client.network.ClientPlayerInteractionManager.interactItem

but the packet was earlier than the PlayerInteractItemC2SPacket.

I also tried a Lingering potion, it have same bug.

@Sodium-Aluminate
Copy link
Author

图片

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant