use of net.minecraft.network.PacketByteBuf in project pingspam by BasiqueEvangelist.
the class PingSpamPackets method register.
public static void register() {
ServerPlayNetworking.registerGlobalReceiver(PULL_PERMISSIONS, (server, player, handler, buf, responseSender) -> {
PacketByteBuf newBuf = PacketByteBufs.create();
newBuf.writeBoolean(Permissions.check(player, "pingspam.ping.everyone", 2));
newBuf.writeBoolean(Permissions.check(player, "pingspam.ping.online", 2));
newBuf.writeBoolean(Permissions.check(player, "pingspam.ping.offline", 2));
newBuf.writeBoolean(Permissions.check(player, "pingspam.ping.player", true));
responseSender.sendPacket(PULL_PERMISSIONS, newBuf);
});
}
use of net.minecraft.network.PacketByteBuf in project wildmod by Osmiooo.
the class SculkShriekerBlock method sendGargleParticles.
public static void sendGargleParticles(World world, BlockPos blockPos) {
if (!world.isClient) {
PacketByteBuf buf = PacketByteBufs.create();
buf.writeBlockPos(blockPos);
int decider = UniformIntProvider.create(0, 1).get(world.getRandom());
// Radius is cut from 32 to 12 in order to slightly help performance/bandwidth since this is kinda spamming tbh
for (ServerPlayerEntity player : PlayerLookup.around((ServerWorld) world, blockPos, 12)) {
if (decider > 0.5) {
ServerPlayNetworking.send(player, RegisterAccurateSculk.SHRIEKER_GARGLE1_PACKET, buf);
} else if (decider < 0.5) {
ServerPlayNetworking.send(player, RegisterAccurateSculk.SHRIEKER_GARGLE2_PACKET, buf);
}
}
}
}
use of net.minecraft.network.PacketByteBuf in project wildmod by Osmiooo.
the class SculkShriekerBlock method sendParticles.
public static void sendParticles(World world, BlockPos blockPos, int direction) {
if (!world.isClient) {
PacketByteBuf buf = PacketByteBufs.create();
buf.writeBlockPos(blockPos);
buf.writeInt(direction);
for (ServerPlayerEntity player : PlayerLookup.around((ServerWorld) world, blockPos, 32)) {
ServerPlayNetworking.send(player, RegisterAccurateSculk.SHRIEKER_SHRIEK_PACKET, buf);
}
}
}
use of net.minecraft.network.PacketByteBuf in project KiwiClient by TangyKiwi.
the class PlayerInteractEntityC2SUtils method getEntity.
public static Entity getEntity(PlayerInteractEntityC2SPacket packet) {
PacketByteBuf packetBuf = new PacketByteBuf(Unpooled.buffer());
packet.write(packetBuf);
return MinecraftClient.getInstance().world.getEntityById(packetBuf.readVarInt());
}
use of net.minecraft.network.PacketByteBuf in project VisualOverhaul by TeamMidnightDust.
the class MixinBrewingStandBlockEntity method tick.
@Inject(at = @At("TAIL"), method = "tick")
private static void tick(World world, BlockPos pos, BlockState state, BrewingStandBlockEntity blockEntity, CallbackInfo ci) {
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));
passedData.writeItemStack(blockEntity.getStack(3));
passedData.writeItemStack(blockEntity.getStack(4));
watchingPlayers.forEach(player -> ServerSidePacketRegistryImpl.INSTANCE.sendToPlayer(player, VisualOverhaul.UPDATE_POTION_BOTTLES, passedData));
invUpdate = false;
}
playerUpdate = world.getPlayers().size();
}
Aggregations