Search in sources :

Example 21 with PacketCommand

use of buildcraft.core.lib.network.command.PacketCommand in project BuildCraft by BuildCraft.

the class TileBuilder method getItemRequirementsPacket.

private Packet getItemRequirementsPacket(List<RequirementItemStack> itemsIn) {
    if (itemsIn != null) {
        final List<RequirementItemStack> items = new ArrayList<>();
        items.addAll(itemsIn);
        return new PacketCommand(this, "setItemRequirements", new CommandWriter() {

            @Override
            public void write(ByteBuf data) {
                data.writeMedium(items.size());
                for (RequirementItemStack rb : items) {
                    data.writeShort(Item.getIdFromItem(rb.stack.getItem()));
                    data.writeShort(rb.stack.getItemDamage());
                    data.writeMedium((rb.stack.hasTagCompound() ? 0x800000 : 0x000000) | Math.min(0x7FFFFF, rb.size));
                    if (rb.stack.hasTagCompound()) {
                        NetworkUtils.writeNBT(data, rb.stack.getTagCompound());
                    }
                }
            }
        });
    } else {
        return new PacketCommand(this, "clearItemRequirements", null);
    }
}
Also used : RequirementItemStack(buildcraft.core.blueprints.RequirementItemStack) ArrayList(java.util.ArrayList) PacketCommand(buildcraft.core.lib.network.command.PacketCommand) CommandWriter(buildcraft.core.lib.network.command.CommandWriter) ByteBuf(io.netty.buffer.ByteBuf)

Example 22 with PacketCommand

use of buildcraft.core.lib.network.command.PacketCommand in project BuildCraft by BuildCraft.

the class ContainerGateInterface method synchronize.

/**
 * Initializes the list of triggers and actions on the gate and (re-)requests the current selection on the gate if
 * needed.
 */
public void synchronize() {
    if (!isNetInitialized && pipe.getTile().getWorldBC().isRemote) {
        isNetInitialized = true;
        BuildCraftCore.instance.sendToServer(new PacketCommand(this, "initRequest", null));
    }
    if (!isSynchronized && pipe.getTile().getWorldBC().isRemote && gate != null) {
        isSynchronized = true;
        BuildCraftCore.instance.sendToServer(new PacketCommand(this, "selectionRequest", null));
    }
}
Also used : PacketCommand(buildcraft.core.lib.network.command.PacketCommand)

Example 23 with PacketCommand

use of buildcraft.core.lib.network.command.PacketCommand in project BuildCraft by BuildCraft.

the class ContainerGateInterface method getStatementParameterPacket.

public Packet getStatementParameterPacket(final String name, final int slot, final int paramSlot, final IStatementParameter parameter) {
    final String parameterName = parameter != null ? parameter.getUniqueTag() : null;
    final NBTTagCompound parameterNBT = new NBTTagCompound();
    if (parameter != null) {
        parameter.writeToNBT(parameterNBT);
    }
    return new PacketCommand(this, name, new CommandWriter() {

        @Override
        public void write(ByteBuf data) {
            data.writeByte(slot);
            data.writeByte(paramSlot);
            NetworkUtils.writeUTF(data, parameterName);
            NetworkUtils.writeNBT(data, parameterNBT);
        }
    });
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PacketCommand(buildcraft.core.lib.network.command.PacketCommand) CommandWriter(buildcraft.core.lib.network.command.CommandWriter) ByteBuf(io.netty.buffer.ByteBuf)

Example 24 with PacketCommand

use of buildcraft.core.lib.network.command.PacketCommand in project BuildCraft by BuildCraft.

the class TileAssemblyTable method rpcSelectRecipe.

public void rpcSelectRecipe(final String id, final boolean select) {
    BuildCraftCore.instance.sendToServer(new PacketCommand(this, "select", new CommandWriter() {

        @Override
        public void write(ByteBuf data) {
            NetworkUtils.writeUTF(data, id);
            data.writeBoolean(select);
        }
    }));
}
Also used : PacketCommand(buildcraft.core.lib.network.command.PacketCommand) CommandWriter(buildcraft.core.lib.network.command.CommandWriter) ByteBuf(io.netty.buffer.ByteBuf)

Example 25 with PacketCommand

use of buildcraft.core.lib.network.command.PacketCommand in project BuildCraft by BuildCraft.

the class ContainerZonePlan method saveArea.

public void saveArea(final int index) {
    BuildCraftCore.instance.sendToServer(new PacketCommand(this, "saveArea", new CommandWriter() {

        @Override
        public void write(ByteBuf data) {
            data.writeByte(index);
            currentAreaSelection.writeData(data);
        }
    }));
}
Also used : PacketCommand(buildcraft.core.lib.network.command.PacketCommand) CommandWriter(buildcraft.core.lib.network.command.CommandWriter) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

PacketCommand (buildcraft.core.lib.network.command.PacketCommand)28 CommandWriter (buildcraft.core.lib.network.command.CommandWriter)25 ByteBuf (io.netty.buffer.ByteBuf)25 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 ItemStack (net.minecraft.item.ItemStack)3 LibraryTypeHandler (buildcraft.api.library.LibraryTypeHandler)2 LibraryTypeHandlerByteArray (buildcraft.api.library.LibraryTypeHandlerByteArray)2 LibraryTypeHandlerNBT (buildcraft.api.library.LibraryTypeHandlerNBT)2 LibraryId (buildcraft.core.blueprints.LibraryId)2 RequirementItemStack (buildcraft.core.blueprints.RequirementItemStack)2 ZonePlan (buildcraft.robotics.zone.ZonePlan)2 IZone (buildcraft.api.core.IZone)1 IMapLocation (buildcraft.api.items.IMapLocation)1 IStatement (buildcraft.api.statements.IStatement)1 IStatementParameter (buildcraft.api.statements.IStatementParameter)1 FillerPattern (buildcraft.core.builders.patterns.FillerPattern)1 Packet (buildcraft.core.lib.network.base.Packet)1 TileZonePlan (buildcraft.robotics.TileZonePlan)1 ContainerZonePlan (buildcraft.robotics.gui.ContainerZonePlan)1