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();
}
}
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();
}
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();
}
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);
}
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);
}
Aggregations