Search in sources :

Example 26 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project BleachHack by BleachDrinker420.

the class PlayerInteractEntityC2SUtils method getInteractType.

public static InteractType getInteractType(PlayerInteractEntityC2SPacket packet) {
    PacketByteBuf packetBuf = new PacketByteBuf(Unpooled.buffer());
    packet.write(packetBuf);
    packetBuf.readVarInt();
    return packetBuf.readEnumConstant(InteractType.class);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 27 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project BleachHack by BleachDrinker420.

the class MixinPacketInflater method decode.

@Inject(method = "decode", at = @At("HEAD"), cancellable = true)
private void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list, CallbackInfo info) throws Exception {
    if (ModuleManager.getModule(AntiChunkBan.class).isEnabled()) {
        info.cancel();
        if (byteBuf.readableBytes() != 0) {
            PacketByteBuf packetByteBuf_1 = new PacketByteBuf(byteBuf);
            int i = packetByteBuf_1.readVarInt();
            if (i == 0) {
                list.add(packetByteBuf_1.readBytes(packetByteBuf_1.readableBytes()));
            } else {
                if (i > 51200000) {
                    throw new DecoderException("Badly compressed packet - size of " + i / 1000000 + "MB is larger than protocol maximum of 50 MB");
                }
                byte[] bs = new byte[packetByteBuf_1.readableBytes()];
                packetByteBuf_1.readBytes(bs);
                this.inflater.setInput(bs);
                byte[] cs = new byte[i];
                this.inflater.inflate(cs);
                list.add(Unpooled.wrappedBuffer(cs));
                this.inflater.reset();
            }
        }
    }
}
Also used : DecoderException(io.netty.handler.codec.DecoderException) AntiChunkBan(org.bleachhack.module.mods.AntiChunkBan) PacketByteBuf(net.minecraft.network.PacketByteBuf) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 28 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project bewitchment by MoriyaShiine.

the class TogglePressingForwardPacket method send.

public static void send(boolean pressingForward) {
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    buf.writeBoolean(pressingForward);
    ClientPlayNetworking.send(ID, buf);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 29 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project bewitchment by MoriyaShiine.

the class SpawnSmokeParticlesPacket method send.

public static void send(PlayerEntity player, Entity entity) {
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    buf.writeInt(entity.getId());
    ServerPlayNetworking.send((ServerPlayerEntity) player, ID, buf);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 30 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project bewitchment by MoriyaShiine.

the class SyncContractsPacket method send.

public static void send(PlayerEntity player) {
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    NbtCompound contracts = new NbtCompound();
    contracts.put("Contracts", BWComponents.CONTRACTS_COMPONENT.get(player).toNbtContract());
    buf.writeNbt(contracts);
    ServerPlayNetworking.send((ServerPlayerEntity) player, ID, buf);
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) PacketByteBuf(net.minecraft.network.PacketByteBuf)

Aggregations

PacketByteBuf (net.minecraft.network.PacketByteBuf)117 PlayerEntity (net.minecraft.entity.player.PlayerEntity)21 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)14 Identifier (net.minecraft.util.Identifier)8 NbtCompound (net.minecraft.nbt.NbtCompound)7 Environment (net.fabricmc.api.Environment)5 CustomPayloadC2SPacket (net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket)5 CustomPayloadS2CPacket (net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket)4 Nullable (org.jetbrains.annotations.Nullable)4 Inject (org.spongepowered.asm.mixin.injection.Inject)4 ArrayList (java.util.ArrayList)3 UUID (java.util.UUID)3 JSONSource (de.modprog.blockmeter.util.JSONSource)2 Map (java.util.Map)2 ServerPlayNetworking (net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking)2 LivingEntity (net.minecraft.entity.LivingEntity)2 CompoundTag (net.minecraft.nbt.CompoundTag)2 ListTag (net.minecraft.nbt.ListTag)2 ParticleType (net.minecraft.particle.ParticleType)2 LiteralText (net.minecraft.text.LiteralText)2