use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ScreenControllerTileEntity method getTags.
@Callback(doc = "Get a table of all tags supported by all connected screens", getter = true)
@Optional.Method(modid = "OpenComputers")
public Object[] getTags(Context context, Arguments args) throws Exception {
List<String> tags = new ArrayList<String>();
for (Coordinate screen : connectedScreens) {
TileEntity te = worldObj.getTileEntity(screen.getX(), screen.getY(), screen.getZ());
if (te instanceof ScreenTileEntity) {
ScreenTileEntity screenTileEntity = (ScreenTileEntity) te;
tags.addAll(screenTileEntity.getTags());
}
}
return new Object[] { tags };
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ScreenControllerTileEntity method detach.
public void detach() {
for (Coordinate c : connectedScreens) {
TileEntity te = worldObj.getTileEntity(c.getX(), c.getY(), c.getZ());
if (te instanceof ScreenTileEntity) {
((ScreenTileEntity) te).setPower(false);
((ScreenTileEntity) te).setConnected(false);
}
}
connectedScreens.clear();
markDirty();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ScreenControllerTileEntity method scan.
private void scan() {
detach();
int radius = 32 + (int) (getInfusedFactor() * 32);
for (int y = yCoord - 16; y <= yCoord + 16; y++) {
if (y >= 0 && y < 256) {
for (int x = xCoord - radius; x <= xCoord + radius; x++) {
for (int z = zCoord - radius; z <= zCoord + radius; z++) {
TileEntity te = worldObj.getTileEntity(x, y, z);
if (te instanceof ScreenTileEntity) {
if (!((ScreenTileEntity) te).isConnected()) {
connectedScreens.add(new Coordinate(x, y, z));
((ScreenTileEntity) te).setConnected(true);
}
}
}
}
}
}
markDirty();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class GuiRFMonitor method setSelectedBlock.
private void setSelectedBlock(int index) {
if (index != -1) {
Coordinate c = adjacentBlocks.get(index);
tileEntity.setMonitor(c);
RFToolsMessages.INSTANCE.sendToServer(new PacketContentsMonitor(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, c));
} else {
tileEntity.setInvalid();
RFToolsMessages.INSTANCE.sendToServer(new PacketContentsMonitor(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, Coordinate.INVALID));
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class GuiRFMonitor method populateList.
private void populateList() {
List<Coordinate> newAdjacentBlocks = fromServer_clientAdjacentBlocks;
if (newAdjacentBlocks == null) {
return;
}
if (newAdjacentBlocks.equals(adjacentBlocks)) {
refreshList();
return;
}
adjacentBlocks = new ArrayList<Coordinate>(newAdjacentBlocks);
list.removeChildren();
int index = 0, sel = -1;
for (Coordinate coordinate : adjacentBlocks) {
Block block = mc.theWorld.getBlock(coordinate.getX(), coordinate.getY(), coordinate.getZ());
int meta = mc.theWorld.getBlockMetadata(coordinate.getX(), coordinate.getY(), coordinate.getZ());
int color = StyleConfig.colorTextInListNormal;
String displayName = BlockInfo.getReadableName(block, coordinate, meta, mc.theWorld);
if (coordinate.getX() == tileEntity.getMonitorX() && coordinate.getY() == tileEntity.getMonitorY() && coordinate.getZ() == tileEntity.getMonitorZ()) {
sel = index;
color = TEXT_COLOR_SELECTED;
}
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout());
panel.addChild(new BlockRender(mc, this).setRenderItem(block));
panel.addChild(new Label(mc, this).setText(displayName).setColor(color).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredWidth(90));
panel.addChild(new Label(mc, this).setDynamic(true).setText(coordinate.toString()).setColor(color));
list.addChild(panel);
index++;
}
list.setSelected(sel);
}
Aggregations