Fix server sync issues

Cancel the PlayerInteractItemC2SPacket instead of the PlayerActionC2SPacket so the trident charge state is properly synced to the server.
This commit is contained in:
KäseToatz
2024-08-02 16:08:20 +02:00
parent d9e2b00679
commit f5e9479079
3 changed files with 3 additions and 6 deletions

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.16.0
# Mod Properties
mod_version = 1.2.4
mod_version = 1.2.5
maven_group = com.kasetoatz
archives_base_name = TridentHacks

View File

@ -7,13 +7,10 @@ import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
import org.lwjgl.glfw.GLFW;
import java.util.HashMap;
public class TridentHacks implements ClientModInitializer {
public static MinecraftClient client;
public static boolean onGround = true;

View File

@ -6,7 +6,7 @@ import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.item.Items;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@ -23,7 +23,7 @@ public abstract class ClientConnectionMixin {
ClientPlayerEntity player = TridentHacks.client.player;
if (player != null)
{
if (player.getActiveItem().getItem() == Items.TRIDENT && player.isUsingItem() && packet instanceof PlayerActionC2SPacket && TridentHacks.noNormalRiptide() && ((PlayerActionC2SPacket)packet).getAction() == PlayerActionC2SPacket.Action.RELEASE_USE_ITEM)
if (packet instanceof PlayerInteractItemC2SPacket && player.getStackInHand(((PlayerInteractItemC2SPacket)packet).getHand()).getItem() == Items.TRIDENT && TridentHacks.noNormalRiptide())
{
ci.cancel();
}