Search in sources :

Example 6 with PacketGetInfoFromServer

use of mcjty.lib.network.clientinfo.PacketGetInfoFromServer in project RFTools by McJty.

the class PowerCellBlock method getWailaBody.

@Override
@SideOnly(Side.CLIENT)
@Optional.Method(modid = "waila")
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
    super.getWailaBody(itemStack, currenttip, accessor, config);
    TileEntity tileEntity = accessor.getTileEntity();
    if (tileEntity instanceof PowerCellTileEntity) {
        PowerCellTileEntity powerCellTileEntity = (PowerCellTileEntity) tileEntity;
        int id = powerCellTileEntity.getNetworkId();
        if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
            if (id != -1) {
                currenttip.add(TextFormatting.GREEN + "ID: " + new DecimalFormat("#.##").format(id));
            } else {
                currenttip.add(TextFormatting.GREEN + "Local storage!");
            }
        }
        if (System.currentTimeMillis() - lastTime > 250) {
            lastTime = System.currentTimeMillis();
            RFToolsMessages.INSTANCE.sendToServer(new PacketGetInfoFromServer(RFTools.MODID, new PowerCellInfoPacketServer(powerCellTileEntity)));
        }
        long total = (PowerCellInfoPacketClient.tooltipBlocks - PowerCellInfoPacketClient.tooltipAdvancedBlocks - (long) PowerCellInfoPacketClient.tooltipSimpleBlocks) * PowerCellConfiguration.rfPerNormalCell;
        total += (long) PowerCellInfoPacketClient.tooltipAdvancedBlocks * PowerCellConfiguration.rfPerNormalCell * advancedFactor;
        total += (long) PowerCellInfoPacketClient.tooltipSimpleBlocks * PowerCellConfiguration.rfPerNormalCell / PowerCellConfiguration.simpleFactor;
        if (total > Integer.MAX_VALUE) {
            total = Integer.MAX_VALUE;
        }
        currenttip.add(TextFormatting.GREEN + "Energy: " + PowerCellInfoPacketClient.tooltipEnergy + "/" + total + " RF (" + PowerCellInfoPacketClient.tooltipRfPerTick + " RF/t)");
        PowerCellTileEntity.Mode mode = powerCellTileEntity.getMode(accessor.getSide());
        if (mode == PowerCellTileEntity.Mode.MODE_INPUT) {
            currenttip.add(TextFormatting.YELLOW + "Side: input");
        } else if (mode == PowerCellTileEntity.Mode.MODE_OUTPUT) {
            int cost = (int) ((PowerCellInfoPacketClient.tooltipCostFactor - 1.0f) * 1000.0f);
            currenttip.add(TextFormatting.YELLOW + "Side: output (cost " + cost / 10 + "." + cost % 10 + "%)");
        }
    }
    return currenttip;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PacketGetInfoFromServer(mcjty.lib.network.clientinfo.PacketGetInfoFromServer) DecimalFormat(java.text.DecimalFormat) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 7 with PacketGetInfoFromServer

use of mcjty.lib.network.clientinfo.PacketGetInfoFromServer in project RFTools by McJty.

the class ScreenBlock method getWailaBodyScreen.

@SideOnly(Side.CLIENT)
@Optional.Method(modid = "waila")
public List<String> getWailaBodyScreen(List<String> currenttip, EntityPlayer player, ScreenTileEntity te) {
    if (!te.isConnected() && te.isControllerNeeded()) {
        currenttip.add(TextFormatting.YELLOW + "[NOT CONNECTED]");
    }
    if (!isCreative()) {
        boolean power = te.isPowerOn();
        if (!power) {
            currenttip.add(TextFormatting.YELLOW + "[NO POWER]");
        }
        if (player.isSneaking()) {
            int rfPerTick = te.getTotalRfPerTick();
            currenttip.add(TextFormatting.GREEN + (power ? "Consuming " : "Needs ") + rfPerTick + " RF/tick");
        }
    }
    if (System.currentTimeMillis() - lastTime > 500) {
        lastTime = System.currentTimeMillis();
        RFToolsMessages.INSTANCE.sendToServer(new PacketGetInfoFromServer(RFTools.MODID, new ScreenInfoPacketServer(te.getWorld().provider.getDimension(), te.getPos())));
    }
    Collections.addAll(currenttip, ScreenInfoPacketClient.infoReceived);
    return currenttip;
}
Also used : PacketGetInfoFromServer(mcjty.lib.network.clientinfo.PacketGetInfoFromServer) ScreenInfoPacketServer(mcjty.rftools.blocks.screens.network.ScreenInfoPacketServer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with PacketGetInfoFromServer

use of mcjty.lib.network.clientinfo.PacketGetInfoFromServer in project RFTools by McJty.

the class GuiPowerCell method requestRF.

private void requestRF() {
    if (System.currentTimeMillis() - lastTime > 250) {
        lastTime = System.currentTimeMillis();
        RFToolsMessages.INSTANCE.sendToServer(new PacketGetInfoFromServer(RFTools.MODID, new PowerCellInfoPacketServer(tileEntity)));
    }
}
Also used : PacketGetInfoFromServer(mcjty.lib.network.clientinfo.PacketGetInfoFromServer)

Aggregations

PacketGetInfoFromServer (mcjty.lib.network.clientinfo.PacketGetInfoFromServer)8 DecimalFormat (java.text.DecimalFormat)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 ItemStack (net.minecraft.item.ItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2 java.awt (java.awt)1 IOException (java.io.IOException)1 java.util (java.util)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 StyleConfig (mcjty.lib.base.StyleConfig)1 GenericGuiContainer (mcjty.lib.container.GenericGuiContainer)1 GhostOutputSlot (mcjty.lib.container.GhostOutputSlot)1 GenericEnergyStorageTileEntity (mcjty.lib.entity.GenericEnergyStorageTileEntity)1 Window (mcjty.lib.gui.Window)1 BlockRenderEvent (mcjty.lib.gui.events.BlockRenderEvent)1 DefaultSelectionEvent (mcjty.lib.gui.events.DefaultSelectionEvent)1 HorizontalAlignment (mcjty.lib.gui.layout.HorizontalAlignment)1 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)1 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)1