use of mcjty.lib.network.clientinfo.PacketGetInfoFromServer in project RFTools by McJty.
the class GuiStorageScanner method requestListsIfNeeded.
private void requestListsIfNeeded() {
listDirty--;
if (listDirty <= 0) {
RFToolsMessages.INSTANCE.sendToServer(new PacketGetInfoFromServer(RFTools.MODID, new InventoriesInfoPacketServer(tileEntity.getDimension(), tileEntity.getStorageScannerPos(), false)));
getInventoryOnServer();
listDirty = 20;
}
}
use of mcjty.lib.network.clientinfo.PacketGetInfoFromServer in project RFTools by McJty.
the class GuiStorageScanner method drawGuiContainerBackgroundLayer.
@Override
protected void drawGuiContainerBackgroundLayer(float v, int i, int i2) {
if (!init) {
return;
}
updateStorageList();
updateContentsList();
requestListsIfNeeded();
String text = radiusLabel.getText();
if ("0".equals(text)) {
text = "XNet";
}
visibleRadiusLabel.setText(text);
int selected = storageList.getSelected();
removeButton.setEnabled(selected != -1);
if (selected <= 0 || storageList.getChildCount() <= 2) {
upButton.setEnabled(false);
downButton.setEnabled(false);
topButton.setEnabled(false);
bottomButton.setEnabled(false);
} else if (selected == 1) {
topButton.setEnabled(false);
upButton.setEnabled(false);
downButton.setEnabled(true);
bottomButton.setEnabled(true);
} else if (selected == storageList.getChildCount() - 1) {
topButton.setEnabled(true);
upButton.setEnabled(true);
downButton.setEnabled(false);
bottomButton.setEnabled(false);
} else {
topButton.setEnabled(true);
upButton.setEnabled(true);
downButton.setEnabled(true);
bottomButton.setEnabled(true);
}
if (!tileEntity.isDummy()) {
tileEntity.requestRfFromServer(RFTools.MODID);
int currentRF = GenericEnergyStorageTileEntity.getCurrentRF();
energyBar.setValue(currentRF);
exportToStarred.setCurrentChoice(tileEntity.isExportToCurrent() ? 0 : 1);
} else {
if (System.currentTimeMillis() - lastTime > 300) {
lastTime = System.currentTimeMillis();
RFToolsMessages.INSTANCE.sendToServer(new PacketGetInfoFromServer(RFTools.MODID, new ScannerInfoPacketServer(tileEntity.getDimension(), tileEntity.getPos())));
}
energyBar.setValue(ScannerInfoPacketClient.rfReceived);
exportToStarred.setCurrentChoice(ScannerInfoPacketClient.exportToCurrentReceived ? 0 : 1);
}
drawWindow();
}
use of mcjty.lib.network.clientinfo.PacketGetInfoFromServer in project RFTools by McJty.
the class GuiStorageScanner method initGui.
@Override
public void initGui() {
super.initGui();
int maxEnergyStored = tileEntity.getMaxEnergyStored();
energyBar = new EnergyBar(mc, this).setFilledRectThickness(1).setVertical().setDesiredWidth(10).setDesiredHeight(50).setMaxValue(maxEnergyStored).setShowText(false);
energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
openViewButton = new ToggleButton(mc, this).setCheckMarker(false).setText("V").setTooltips("Toggle wide storage list");
openViewButton.setPressed(tileEntity.isOpenWideView());
openViewButton.addButtonEvent(widget -> toggleView());
upButton = new Button(mc, this).setText("U").setTooltips("Move inventory up").addButtonEvent(widget -> moveUp());
topButton = new Button(mc, this).setText("T").setTooltips("Move inventory to the top").addButtonEvent(widget -> moveTop());
downButton = new Button(mc, this).setText("D").setTooltips("Move inventory down").addButtonEvent(widget -> moveDown());
bottomButton = new Button(mc, this).setText("B").setTooltips("Move inventory to the bottom").addButtonEvent(widget -> moveBottom());
removeButton = new Button(mc, this).setText("R").setTooltips("Remove inventory from list").addButtonEvent(widget -> removeFromList());
Panel energyPanel = new Panel(mc, this).setLayout(new VerticalLayout().setVerticalMargin(0).setSpacing(1)).setDesiredWidth(10);
energyPanel.addChild(openViewButton).addChild(energyBar).addChild(topButton).addChild(upButton).addChild(downButton).addChild(bottomButton).addChild(new Label(mc, this).setText(" ")).addChild(removeButton);
exportToStarred = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(12, 223, 13, 13)).addChoiceEvent((parent, newChoice) -> changeExportMode());
exportToStarred.addChoice("No", "Export to current container", guielements, 131, 19);
exportToStarred.addChoice("Yes", "Export to first routable container", guielements, 115, 19);
storagePanel = makeStoragePanel(energyPanel);
itemPanel = makeItemPanel();
Button scanButton = new Button(mc, this).setText("Scan").setDesiredWidth(50).setDesiredHeight(14).addButtonEvent(parent -> RFToolsMessages.INSTANCE.sendToServer(new PacketGetInfoFromServer(RFTools.MODID, new InventoriesInfoPacketServer(tileEntity.getDimension(), tileEntity.getStorageScannerPos(), true))));
if (RFTools.instance.xnet) {
if (StorageScannerConfiguration.xnetRequired) {
scanButton.setTooltips("Do a scan of all", "storage units connected", "with an active XNet channel");
} else {
scanButton.setTooltips("Do a scan of all", "storage units in radius", "Use 'xnet' radius to", "restrict to XNet only");
}
} else {
scanButton.setTooltips("Do a scan of all", "storage units in radius");
}
radiusLabel = new ScrollableLabel(mc, this).addValueEvent((parent, newValue) -> changeRadius(newValue)).setRealMinimum(RFTools.instance.xnet ? 0 : 1).setRealMaximum(20);
radiusLabel.setRealValue(tileEntity.getRadius());
visibleRadiusLabel = new Label(mc, this);
visibleRadiusLabel.setDesiredWidth(40);
searchField = new TextField(mc, this).addTextEvent((parent, newText) -> {
storageList.clearHilightedRows();
fromServer_foundInventories.clear();
startSearch(newText);
});
Panel searchPanel = new Panel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(8, 142, 256 - 11, 18)).setLayout(new HorizontalLayout()).setDesiredHeight(18).addChild(new Label(mc, this).setText("Search:")).addChild(searchField);
Slider radiusSlider = new Slider(mc, this).setHorizontal().setTooltips("Radius of scan").setMinimumKnobSize(12).setDesiredHeight(14).setScrollable(radiusLabel);
Panel scanPanel = new Panel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(8, 162, 74, 54)).setFilledRectThickness(-2).setFilledBackground(StyleConfig.colorListBackground).setLayout(new VerticalLayout().setVerticalMargin(6).setSpacing(1)).addChild(scanButton);
if (!(RFTools.instance.xnet && StorageScannerConfiguration.xnetRequired)) {
scanPanel.addChild(radiusSlider);
}
scanPanel.addChild(visibleRadiusLabel);
if (tileEntity.isDummy()) {
scanButton.setEnabled(false);
radiusLabel.setVisible(false);
radiusSlider.setVisible(false);
}
Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(storagePanel).addChild(itemPanel).addChild(searchPanel).addChild(scanPanel).addChild(exportToStarred);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
window = new Window(this, toplevel);
Keyboard.enableRepeatEvents(true);
fromServer_foundInventories.clear();
fromServer_inventory.clear();
if (tileEntity.isDummy()) {
fromServer_inventories.clear();
} else {
tileEntity.requestRfFromServer(RFTools.MODID);
}
BlockPos pos = tileEntity.getCraftingGridContainerPos();
craftingGrid.initGui(modBase, network, mc, this, pos, tileEntity.getCraftingGridProvider(), guiLeft, guiTop, xSize, ySize);
sendServerCommand(RFTools.MODID, CommandHandler.CMD_REQUEST_GRID_SYNC, Arguments.builder().value(pos).build());
if (StorageScannerConfiguration.hilightStarredOnGuiOpen) {
storageList.setSelected(0);
}
init = true;
}
use of mcjty.lib.network.clientinfo.PacketGetInfoFromServer in project RFTools by McJty.
the class SpawnerBlock method getWailaBody.
@SideOnly(Side.CLIENT)
@Override
@Optional.Method(modid = "waila")
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
super.getWailaBody(itemStack, currenttip, accessor, config);
TileEntity te = accessor.getTileEntity();
if (te instanceof SpawnerTileEntity) {
SpawnerTileEntity spawnerTileEntity = (SpawnerTileEntity) te;
if (System.currentTimeMillis() - lastTime > 500) {
lastTime = System.currentTimeMillis();
RFToolsMessages.INSTANCE.sendToServer(new PacketGetInfoFromServer(RFTools.MODID, new SpawnerInfoPacketServer(te.getWorld().provider.getDimension(), te.getPos())));
}
float[] matter = SpawnerInfoPacketClient.matterReceived;
if (matter != null && matter.length == 3) {
DecimalFormat fmt = new DecimalFormat("#.##");
fmt.setRoundingMode(RoundingMode.DOWN);
currenttip.add(TextFormatting.GREEN + "Key Matter: " + fmt.format(matter[0]));
currenttip.add(TextFormatting.GREEN + "Bulk Matter: " + fmt.format(matter[1]));
currenttip.add(TextFormatting.GREEN + "Living Matter: " + fmt.format(matter[2]));
}
}
return currenttip;
}
use of mcjty.lib.network.clientinfo.PacketGetInfoFromServer in project RFTools by McJty.
the class GuiSpawner method showSyringeInfo.
private void showSyringeInfo() {
for (int i = 0; i < 3; i++) {
blocks[i].setRenderItem(null);
labels[i].setText("");
}
name.setText("");
rfTick.setText("");
ItemStack stack = tileEntity.getStackInSlot(SpawnerContainer.SLOT_SYRINGE);
if (stack.isEmpty()) {
return;
}
String mobId = SyringeItem.getMobId(stack);
if (mobId != null) {
String mobName = SyringeItem.getMobName(stack);
name.setText(mobName);
rfTick.setText(SpawnerConfiguration.mobSpawnRf.get(mobId) + "RF");
int i = 0;
List<SpawnerConfiguration.MobSpawnAmount> list = SpawnerConfiguration.mobSpawnAmounts.get(mobId);
if (list != null) {
if (System.currentTimeMillis() - lastTime > 100) {
lastTime = System.currentTimeMillis();
RFToolsMessages.INSTANCE.sendToServer(new PacketGetInfoFromServer(RFTools.MODID, new SpawnerInfoPacketServer(tileEntity.getWorld().provider.getDimension(), tileEntity.getPos())));
}
float[] matter = SpawnerInfoPacketClient.matterReceived;
if (matter == null || matter.length != 3) {
matter = new float[] { 0, 0, 0 };
}
for (SpawnerConfiguration.MobSpawnAmount spawnAmount : list) {
ItemStack b = spawnAmount.getObject();
float amount = spawnAmount.getAmount();
if (b.isEmpty()) {
Object[] blocks = { Blocks.LEAVES, Blocks.PUMPKIN, Items.WHEAT, Items.POTATO, Items.BEEF };
int index = (int) ((System.currentTimeMillis() / 500) % blocks.length);
if (blocks[index] instanceof Block) {
this.blocks[i].setRenderItem(new ItemStack((Block) blocks[index], 1, 0));
} else {
this.blocks[i].setRenderItem(new ItemStack((Item) blocks[index], 1, 0));
}
} else {
blocks[i].setRenderItem(b);
}
DecimalFormat format = new DecimalFormat("#.##");
format.setRoundingMode(RoundingMode.DOWN);
String mf = format.format(matter[i]);
labels[i].setText(mf + "/" + Float.toString(amount));
i++;
}
}
}
}
Aggregations