Update to 1.20.6
This commit is contained in:
@ -19,35 +19,22 @@
|
||||
|
||||
package de.steamwar.advancedscripts.mixin;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import de.steamwar.advancedscripts.KeyAction;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Keyboard.class)
|
||||
public class KeyboardMixin {
|
||||
|
||||
@Unique
|
||||
private static final Identifier channel = new Identifier("sw:hotkeys");
|
||||
|
||||
@Inject(method = "onKey", at = @At("HEAD"))
|
||||
public void sendKeyPress(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) {
|
||||
MinecraftClient client = ((Keyboard) (Object)this).client;
|
||||
if(client.currentScreen == null && action != 2) {
|
||||
PacketByteBuf byteBuf = new PacketByteBuf(Unpooled.buffer());
|
||||
byteBuf.writeInt(key);
|
||||
byteBuf.writeByte(action);
|
||||
byteBuf.writeInt(modifiers);
|
||||
CustomPayloadC2SPacket customPayloadC2SPacket = new CustomPayloadC2SPacket(channel,byteBuf);
|
||||
client.getNetworkHandler().sendPacket(customPayloadC2SPacket);
|
||||
client.getNetworkHandler().sendPacket(new CustomPayloadC2SPacket(new KeyAction(key, (byte) action, modifiers)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user