use of buildcraft.core.lib.network.base.Packet in project BuildCraft by BuildCraft.
the class TileGenericPipe method update.
@Override
public void update() {
try {
if (!worldObj.isRemote) {
if (deletePipe) {
worldObj.setBlockToAir(getPos());
}
if (pipe == null || coreState.pipeId == null) {
return;
}
if (!initialized) {
initialize(pipe);
}
}
if (attachPluggables) {
attachPluggables = false;
// Attach callback
for (int i = 0; i < EnumFacing.VALUES.length; i++) {
if (sideProperties.pluggables[i] != null) {
pipe.eventBus.registerHandler(sideProperties.pluggables[i]);
sideProperties.pluggables[i].onAttachedPipe(this, EnumFacing.getFront(i));
}
}
notifyBlockChanged();
}
if (!BlockGenericPipe.isValid(pipe)) {
return;
}
pipe.updateEntity();
for (EnumFacing direction : EnumFacing.VALUES) {
PipePluggable p = getPipePluggable(direction);
if (p != null) {
p.update(this, direction);
}
}
if (worldObj.isRemote) {
if (resyncGateExpansions) {
syncGateExpansions();
}
return;
}
if (blockNeighborChange) {
for (int i = 0; i < 6; i++) {
if ((blockNeighborChangedSides & (1 << i)) != 0) {
blockNeighborChangedSides ^= 1 << i;
computeConnection(EnumFacing.getFront(i));
}
}
pipe.onNeighborBlockChange(0);
blockNeighborChange = false;
refreshRenderState = true;
}
if (refreshRenderState) {
refreshRenderState();
refreshRenderState = false;
}
if (sendClientUpdate) {
sendClientUpdate = false;
if (!worldObj.isRemote) {
Packet updatePacket = getBCDescriptionPacket();
BuildCraftCore.instance.sendToPlayersNear(updatePacket, this);
}
}
} catch (Throwable t) {
BCLog.logger.warn("CRASH! OH NO!", t);
Throwables.propagate(t);
}
}
use of buildcraft.core.lib.network.base.Packet in project BuildCraft by BuildCraft.
the class TileGenericPipe method getUpdatePacket.
@Override
public SPacketUpdateTileEntity getUpdatePacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("net-type", "desc-packet");
Packet p = getBCDescriptionPacket();
ByteBuf buf = Unpooled.buffer();
p.writeData(buf);
byte[] bytes = new byte[buf.readableBytes()];
buf.readBytes(bytes);
nbt.setByteArray("net-data", bytes);
SPacketUpdateTileEntity tileUpdate = new SPacketUpdateTileEntity(getPos(), 0, nbt);
return tileUpdate;
}
use of buildcraft.core.lib.network.base.Packet in project BuildCraft by BuildCraft.
the class TileZonePlan method importMap.
private void importMap(ItemStack stack) {
if (stack != null && stack.getItem() instanceof IMapLocation) {
final IZone zone = ((IMapLocation) stack.getItem()).getZone(stack);
if (zone != null && zone instanceof ZonePlan) {
selectedAreas[currentSelectedArea] = (ZonePlan) zone;
for (EntityPlayerMP e : MinecraftServer.getServer().getConfigurationManager().playerEntityList) {
if (e.openContainer != null && e.openContainer instanceof ContainerZonePlan && ((ContainerZonePlan) e.openContainer).getTile() == this) {
Packet p = new PacketCommand(e.openContainer, "areaLoaded", new CommandWriter() {
@Override
public void write(ByteBuf data) {
((ZonePlan) zone).writeData(data);
}
});
BuildCraftCore.instance.sendToPlayer(e, p);
}
}
}
}
}
use of buildcraft.core.lib.network.base.Packet in project BuildCraft by BuildCraft.
the class TileBuildCraft method getUpdatePacket.
@Override
public SPacketUpdateTileEntity getUpdatePacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("net-type", "desc-packet");
Packet p = getPacketUpdate();
ByteBuf buf = Unpooled.buffer();
p.writeData(buf);
byte[] bytes = new byte[buf.readableBytes()];
buf.readBytes(bytes);
nbt.setByteArray("net-data", bytes);
SPacketUpdateTileEntity tileUpdate = new SPacketUpdateTileEntity(getPos(), 0, nbt);
return tileUpdate;
}
use of buildcraft.core.lib.network.base.Packet in project BuildCraft by BuildCraft.
the class PacketPipeTransportItemStackRequest method sendDataToPlayer.
public void sendDataToPlayer(EntityPlayer player) {
if (item != null) {
Packet packet = new PacketPipeTransportItemStack(player.worldObj, travelerID, item.getItemStack());
BuildCraftTransport.instance.sendToPlayer(player, packet);
}
}
Aggregations