use of buildcraft.core.lib.network.command.PacketCommand in project BuildCraft by BuildCraft.
the class EntityRobot method setItemInUse.
@Override
public void setItemInUse(ItemStack stack) {
itemInUse = stack;
BuildCraftCore.instance.sendToEntity(new PacketCommand(this, "clientSetItemInUse", new CommandWriter() {
@Override
public void write(ByteBuf data) {
NetworkUtils.writeStack(data, itemInUse);
}
}), this);
}
use of buildcraft.core.lib.network.command.PacketCommand in project BuildCraft by BuildCraft.
the class EntityRobot method setSteamDirection.
private void setSteamDirection(final Vec3d direction) {
if (!worldObj.isRemote) {
BuildCraftCore.instance.sendToEntity(new PacketCommand(this, "setSteamDirection", new CommandWriter() {
@Override
public void write(ByteBuf data) {
data.writeDouble(direction.xCoord);
data.writeDouble(direction.yCoord);
data.writeDouble(direction.zCoord);
}
}), this);
} else {
steamDirection = direction.normalize();
}
}
use of buildcraft.core.lib.network.command.PacketCommand in project BuildCraft by BuildCraft.
the class EntityRobot method setItemActive.
@Override
public void setItemActive(final boolean isActive) {
if (isActive != itemActive) {
itemActive = isActive;
BuildCraftCore.instance.sendToEntity(new PacketCommand(this, "setItemActive", new CommandWriter() {
@Override
public void write(ByteBuf data) {
data.writeBoolean(isActive);
}
}), this);
}
}
use of buildcraft.core.lib.network.command.PacketCommand in project BuildCraft by BuildCraft.
the class EntityRobot method receiveCommand.
@Override
public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) {
if (side.isClient()) {
if ("clientSetItemInUse".equals(command)) {
itemInUse = NetworkUtils.readStack(stream);
} else if ("clientSetInventory".equals(command)) {
int slot = stream.readUnsignedShort();
inv[slot] = NetworkUtils.readStack(stream);
} else if ("initialize".equals(command)) {
itemInUse = NetworkUtils.readStack(stream);
itemActive = stream.readBoolean();
} else if ("setItemActive".equals(command)) {
itemActive = stream.readBoolean();
itemActiveStage = 0;
lastUpdateTime = new Date().getTime();
if (!itemActive) {
setSteamDirection(new Vec3d(0, -1, 0));
}
} else if ("setSteamDirection".equals(command)) {
setSteamDirection(new Vec3d(stream.readDouble(), stream.readDouble(), stream.readDouble()));
} else if ("syncWearables".equals(command)) {
wearables.clear();
int amount = stream.readUnsignedByte();
while (amount > 0) {
wearables.add(NetworkUtils.readStack(stream));
amount--;
}
}
} else if (side.isServer()) {
EntityPlayer p = (EntityPlayer) sender;
if ("requestInitialization".equals(command)) {
BuildCraftCore.instance.sendToPlayer(p, new PacketCommand(this, "initialize", new CommandWriter() {
@Override
public void write(ByteBuf data) {
NetworkUtils.writeStack(data, itemInUse);
data.writeBoolean(itemActive);
}
}));
for (int i = 0; i < inv.length; ++i) {
final int j = i;
BuildCraftCore.instance.sendToPlayer(p, new PacketCommand(this, "clientSetInventory", new CommandWriter() {
@Override
public void write(ByteBuf data) {
data.writeShort(j);
NetworkUtils.writeStack(data, inv[j]);
}
}));
}
if (currentDockingStation != null) {
setSteamDirection(Utils.convert(currentDockingStation.side()));
} else {
setSteamDirection(new Vec3d(0, -1, 0));
}
}
}
}
use of buildcraft.core.lib.network.command.PacketCommand in project BuildCraft by BuildCraft.
the class ContainerRefinery method setFilter.
/* SETTING AND GETTING FILTERS */
public void setFilter(final int slot, final Fluid filter) {
refinery.setFilter(slot, filter);
if (refinery.getWorld().isRemote) {
CommandWriter payload = new CommandWriter() {
@Override
public void write(ByteBuf data) {
data.writeByte(slot);
data.writeShort(filter != null ? filter.getID() : -1);
}
};
BuildCraftFactory.instance.sendToServer(new PacketCommand(refinery, "setFilter", payload));
}
}
Aggregations