use of net.minecraft.network.PacketBuffer in project SpongeVanilla by SpongePowered.
the class VanillaIndexedMessageChannel method createPacket.
private SPacketCustomPayload createPacket(Message message) {
Class<? extends Message> messageClass = message.getClass();
IndexedMessageType<?> type = this.messageClasses.get(messageClass);
checkNotNull(type, "Unknown message type %s of %s", messageClass, message);
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
buffer.writeByte(type.id);
buffer.markWriterIndex();
message.writeTo(SpongeNetworkManager.toChannelBuf(buffer));
return new SPacketCustomPayload(getName(), buffer);
}
use of net.minecraft.network.PacketBuffer in project Bewitchment by Um-Mitternacht.
the class ParticleMessage method toBytes.
@Override
public void toBytes(ByteBuf byteBuf) {
PacketBuffer buf = new PacketBuffer(byteBuf);
buf.writeEnumValue(particleF);
buf.writeDouble(x);
buf.writeDouble(y);
buf.writeDouble(z);
buf.writeInt(amount);
buf.writeDouble(xSpeed);
buf.writeDouble(ySpeed);
buf.writeDouble(zSpeed);
buf.writeInt(args.length);
for (int arg : args) {
buf.writeInt(arg);
}
}
use of net.minecraft.network.PacketBuffer in project BuildCraft by BuildCraft.
the class MessageWireSystems method toBytes.
@Override
public void toBytes(ByteBuf buf) {
PacketBuffer pb = new PacketBuffer(buf);
pb.writeInt(wireSystems.size());
wireSystems.forEach((wiresHashCode, wireSystem) -> {
pb.writeInt(wiresHashCode);
List<WireSystem.WireElement> elements = wireSystem.elements.stream().filter(element -> element.type == WireSystem.WireElement.Type.WIRE_PART).collect(Collectors.toList());
pb.writeInt(elements.size());
elements.forEach(element -> element.toBytes(pb));
});
}
use of net.minecraft.network.PacketBuffer in project artisan-worktables by codetaylor.
the class CPacketWorktableFluidUpdate method toBytes.
@Override
public void toBytes(ByteBuf buf) {
super.toBytes(buf);
PacketBuffer packetBuffer = new PacketBuffer(buf);
packetBuffer.writeCompoundTag(this.fluidTank.writeToNBT(new NBTTagCompound()));
}
use of net.minecraft.network.PacketBuffer in project artisan-worktables by codetaylor.
the class CPacketWorktableFluidUpdate method fromBytes.
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
PacketBuffer packetBuffer = new PacketBuffer(buf);
try {
NBTTagCompound compound = packetBuffer.readCompoundTag();
this.fluidTank = new FluidTank(0);
if (compound != null) {
this.fluidTank.readFromNBT(compound);
}
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations