Search in sources :

Example 36 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project VisualOverhaul by TeamMidnightDust.

the class MixinAbstractFurnaceBlockEntity method tick.

@Inject(at = @At("TAIL"), method = "tick")
private static void tick(World world, BlockPos pos, BlockState state, AbstractFurnaceBlockEntity blockEntity, CallbackInfo ci) {
    if (world.getBlockState(pos).hasBlockEntity()) {
        if (!world.isClient && (invUpdate || world.getPlayers().size() == playerUpdate)) {
            Stream<ServerPlayerEntity> watchingPlayers = PlayerLookup.tracking(blockEntity).stream();
            PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
            passedData.writeBlockPos(pos);
            passedData.writeItemStack(blockEntity.getStack(0));
            passedData.writeItemStack(blockEntity.getStack(1));
            passedData.writeItemStack(blockEntity.getStack(2));
            watchingPlayers.forEach(player -> ServerSidePacketRegistryImpl.INSTANCE.sendToPlayer(player, VisualOverhaul.UPDATE_FURNACE_ITEMS, passedData));
            invUpdate = false;
        }
        playerUpdate = world.getPlayers().size();
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 37 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project VisualOverhaul by TeamMidnightDust.

the class MixinJukeboxBlock method tick.

@Unique
private static void tick(World world, BlockPos pos, BlockState state, JukeboxBlockEntity blockEntity) {
    if (!world.isClient && (JukeboxPacketUpdate.invUpdate || world.getPlayers().size() == JukeboxPacketUpdate.playerUpdate)) {
        Stream<ServerPlayerEntity> watchingPlayers = PlayerLookup.tracking(blockEntity).stream();
        PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
        passedData.writeBlockPos(pos);
        passedData.writeItemStack(blockEntity.getRecord());
        watchingPlayers.forEach(player -> ServerSidePacketRegistryImpl.INSTANCE.sendToPlayer(player, VisualOverhaul.UPDATE_RECORD, passedData));
        JukeboxPacketUpdate.invUpdate = false;
    }
    JukeboxPacketUpdate.playerUpdate = world.getPlayers().size();
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Unique(org.spongepowered.asm.mixin.Unique)

Example 38 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project VisualOverhaul by TeamMidnightDust.

the class MixinJukeboxBlockEntity method tick.

@Unique
private static void tick(World world, BlockPos pos, BlockState state, JukeboxBlockEntity blockEntity) {
    if (!world.isClient && (JukeboxPacketUpdate.invUpdate || world.getPlayers().size() == JukeboxPacketUpdate.playerUpdate)) {
        Stream<ServerPlayerEntity> watchingPlayers = PlayerLookup.tracking(blockEntity).stream();
        PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
        passedData.writeBlockPos(pos);
        passedData.writeItemStack(blockEntity.getRecord());
        watchingPlayers.forEach(player -> ServerSidePacketRegistryImpl.INSTANCE.sendToPlayer(player, VisualOverhaul.UPDATE_RECORD, passedData));
        JukeboxPacketUpdate.invUpdate = false;
    }
    JukeboxPacketUpdate.playerUpdate = world.getPlayers().size();
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Unique(org.spongepowered.asm.mixin.Unique)

Example 39 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project KiwiClient by TangyKiwi.

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 40 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project pingspam by BasiqueEvangelist.

the class ServerNetworkLogic method addPossibleName.

public static void addPossibleName(PlayerManager manager, String possibleName) {
    PacketByteBuf diffBuf = PacketByteBufs.create();
    diffBuf.writeVarInt(1);
    diffBuf.writeString(possibleName);
    diffBuf.writeVarInt(0);
    sendToAll(manager, PingSpamPackets.POSSIBLE_NAMES_DIFF, diffBuf);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Aggregations

PacketByteBuf (net.minecraft.network.PacketByteBuf)156 PlayerEntity (net.minecraft.entity.player.PlayerEntity)40 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)17 Identifier (net.minecraft.util.Identifier)12 CustomPayloadS2CPacket (net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket)9 NbtCompound (net.minecraft.nbt.NbtCompound)7 CustomPayloadC2SPacket (net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket)7 Inject (org.spongepowered.asm.mixin.injection.Inject)6 Environment (net.fabricmc.api.Environment)5 UUID (java.util.UUID)4 LivingEntity (net.minecraft.entity.LivingEntity)4 Nullable (org.jetbrains.annotations.Nullable)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 LiteralText (net.minecraft.text.LiteralText)3 GenderPlayer (com.wildfire.main.GenderPlayer)2 JSONSource (de.modprog.blockmeter.util.JSONSource)2 IHungerManager (de.siphalor.spiceoffabric.util.IHungerManager)2 HWGEntity (mod.azure.hwg.entity.HWGEntity)2 ServerPlayNetworking (net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking)2