Search in sources :

Example 71 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project BlockMeter by ModProg.

the class BlockMeterClient method sendBoxList.

/**
 * Sends BoxList to Server if enabled in the config
 */
private void sendBoxList() {
    if (!AutoConfig.getConfigHolder(ModConfig.class).getConfig().sendBoxes)
        return;
    PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
    passedData.writeInt(boxes.size());
    for (int i = 0; i < boxes.size(); i++) {
        boxes.get(i).writePacketBuf(passedData);
    }
    ClientPlayNetworking.send(BlockMeter.C2SPacketIdentifier, passedData);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 72 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project BlockMeter by ModProg.

the class MeasureBoxTest method testPacketByteBuf.

@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseBlockPos.class, ParseIdentifier.class, ParseDyeColor.class, Boolean.class }, jsons = { "(11|2|-50), (0|0|0), overworld, red, true", "(10020|45|130), (10000|99|203), end, blue, false", "(17|0|40), (40|256|70), overworld, red, true", "(-1455|2|-6000), (-1455|32|-5000), overworld, red, true" })
void testPacketByteBuf(BlockPos bp1, BlockPos bp2, Identifier dimension, DyeColor color, boolean finished) {
    final PacketByteBuf expectedBuf = new PacketByteBuf(Unpooled.buffer());
    expectedBuf.writeBlockPos(bp1);
    expectedBuf.writeBlockPos(bp2);
    expectedBuf.writeIdentifier(dimension);
    expectedBuf.writeInt(color.getId());
    expectedBuf.writeBoolean(finished);
    expectedBuf.writeInt(0);
    expectedBuf.writeInt(0);
    final MeasureBox mb = MeasureBox.fromPacketByteBuf(expectedBuf);
    final PacketByteBuf actualBuf = new PacketByteBuf(Unpooled.buffer());
    mb.writePacketBuf(actualBuf);
    expectedBuf.resetReaderIndex();
    assertThat(expectedBuf).isEqualTo(actualBuf);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) MeasureBox(win.baruna.blockmeter.measurebox.MeasureBox) JSONSource(de.modprog.blockmeter.util.JSONSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 73 with PacketByteBuf

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

the class TransformationAbilityPacket method send.

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

Example 74 with PacketByteBuf

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

the class SpawnExplosionParticlesPacket 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 75 with PacketByteBuf

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

the class SpawnPortalParticlesPacket 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)

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