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);
}
}
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));
}
}
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);
}
});
}
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);
}
}));
}
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);
}
}));
}
Aggregations