Java Code Examples for net.minecraft.util.PacketByteBuf#writeInt()

The following examples show how to use net.minecraft.util.PacketByteBuf#writeInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FMLPlayMessages.java    From patchwork-api with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void encode(SpawnEntity msg, PacketByteBuf buf) {
	buf.writeVarInt(msg.typeId);
	buf.writeInt(msg.entityId);
	buf.writeUuid(msg.uuid);
	buf.writeDouble(msg.posX);
	buf.writeDouble(msg.posY);
	buf.writeDouble(msg.posZ);
	buf.writeByte(msg.pitch);
	buf.writeByte(msg.yaw);
	buf.writeByte(msg.headYaw);
	buf.writeShort(msg.velX);
	buf.writeShort(msg.velY);
	buf.writeShort(msg.velZ);

	if (msg.entity instanceof IEntityAdditionalSpawnData) {
		((IEntityAdditionalSpawnData) msg.entity).writeSpawnData(buf);
	}
}
 
Example 2
Source File: HallowedTreasureChestEntity.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public Packet<?> createSpawnPacket() {
	PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer());
	
	packet.writeDouble(getX());
	packet.writeDouble(getY());
	packet.writeDouble(getZ());
	
	packet.writeBoolean(shouldReplace);
	packet.writeFloat(rotation);
	
	packet.writeInt(getEntityId());
	
	return ServerSidePacketRegistry.INSTANCE.toPacket(ENTITY_ID, packet);
}
 
Example 3
Source File: AddonS2CPacket.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void write(PacketByteBuf var1) {
    var1.writeInt(count);
    var1.writeString(prefix);
    addons.forEach(pair -> {
        var1.writeString(pair.getLeft(), Short.MAX_VALUE);
        var1.writeString(pair.getRight(), Short.MAX_VALUE);
    });
}
 
Example 4
Source File: FluidRecipeSerializer.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public void write(PacketByteBuf buf, FluidRecipe recipe) {
	buf.writeInt(recipe.getIngredients().size());
	recipe.getIngredients().forEach(ingredient -> ingredient.write(buf));
	buf.writeItemStack(recipe.getOutput());
}
 
Example 5
Source File: ContainerOpenPacket.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void write(PacketByteBuf buf) {
    buf.writeIdentifier(WrappingUtil.convert(id));
    buf.writeInt(syncId);
    buf.writeCompoundTag((net.minecraft.nbt.CompoundTag) data);
}