Search in sources :

Example 1 with TileLegacyMachineBase

use of reborncore.common.tile.TileLegacyMachineBase in project TechReborn by TechReborn.

the class SlotConfigPopupElement method draw.

@Override
public void draw(GuiBase gui) {
    drawDefaultBackground(gui, adjustX(gui, getX() - 8), adjustY(gui, getY() - 7), 84, 105 + (filter ? 15 : 0));
    super.draw(gui);
    TileLegacyMachineBase machine = ((TileLegacyMachineBase) gui.tile);
    IBlockAccess blockAccess = machine.getWorld();
    BlockPos pos = machine.getPos();
    IBlockState state = blockAccess.getBlockState(pos);
    IBlockState actualState = state.getBlock().getDefaultState().getActualState(blockAccess, pos);
    BlockRendererDispatcher dispatcher = FMLClientHandler.instance().getClient().getBlockRendererDispatcher();
    IBakedModel model = dispatcher.getBlockModelShapes().getModelForState(state.getBlock().getDefaultState());
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    // left
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 4, 23);
    // top
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, -12, -90F, 1F, 0F, 0F);
    // centre
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 23, -90F, 0F, 1F, 0F);
    // bottom
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 42, 90F, 1F, 0F, 0F);
    // right
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 23, 180F, 0F, 1F, 0F);
    // back
    drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 42, 90F, 0F, 1F, 0F);
    drawSlotSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui);
    drawSlotSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, gui);
    drawSlotSateColor(gui.getMachine(), MachineFacing.DOWN.getFacing(machine), id, 22, 37, gui);
    drawSlotSateColor(gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), id, 41, 18, gui);
    drawSlotSateColor(gui.getMachine(), MachineFacing.BACK.getFacing(machine), id, 41, 37, gui);
    drawSlotSateColor(gui.getMachine(), MachineFacing.LEFT.getFacing(machine), id, 3, 18, gui);
}
Also used : TileLegacyMachineBase(reborncore.common.tile.TileLegacyMachineBase) IBlockState(net.minecraft.block.state.IBlockState) IBlockAccess(net.minecraft.world.IBlockAccess) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 2 with TileLegacyMachineBase

use of reborncore.common.tile.TileLegacyMachineBase in project TechReborn by TechReborn.

the class ProbeProvider method addProbeInfo.

@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    euStyle = new ProgressStyle().backgroundColor(0xFF8B8B8B).borderColor(0xFF373737).alternateFilledColor(PowerSystem.getDisplayPower().altColour).filledColor(PowerSystem.getDisplayPower().colour);
    euStyle.suffix(" " + PowerSystem.getDisplayPower().abbreviation);
    TileEntity tile = world.getTileEntity(data.getPos());
    if (tile instanceof IListInfoProvider) {
        List<String> strs = new ArrayList<>();
        ((IListInfoProvider) tile).addInfo(strs, true);
        for (String string : strs) {
            probeInfo.text(string);
        }
    }
    if (tile instanceof IEnergyInterfaceTile) {
        IEnergyInterfaceTile energy = (IEnergyInterfaceTile) tile;
        if (PowerSystem.getDisplayPower() != PowerSystem.EnergySystem.EU) {
            probeInfo.progress((int) energy.getEnergy() * RebornCoreConfig.euPerFU, (int) energy.getMaxPower() * RebornCoreConfig.euPerFU, euStyle);
        } else {
            probeInfo.progress((int) energy.getEnergy(), (int) energy.getMaxPower(), euStyle);
        }
    }
    if (tile instanceof TileLegacyMachineBase && methodHandle_addStacks != null) {
        TileLegacyMachineBase legacyMachineBase = (TileLegacyMachineBase) tile;
        if (legacyMachineBase.getInventoryForTile().isPresent()) {
            if (player.isSneaking()) {
                probeInfo.text(I18n.translateToLocal("techreborn.tooltip.inventory"));
            }
            Inventory inventory = legacyMachineBase.getInventoryForTile().get();
            if (!inventory.isEmpty()) {
                List<ItemStack> stacks = Arrays.stream(inventory.contents).filter(stack -> !stack.isEmpty()).collect(Collectors.toList());
                try {
                    methodHandle_addStacks.invoke(probeInfo, world, null, stacks, player.isSneaking());
                } catch (Throwable throwable) {
                    throwable.printStackTrace();
                }
            }
        }
        if (!legacyMachineBase.upgradeInventory.isEmpty() && player.isSneaking()) {
            probeInfo.horizontal();
            probeInfo.text(I18n.translateToLocal("techreborn.tooltip.upgrades"));
            List<ItemStack> stacks = Arrays.stream(legacyMachineBase.upgradeInventory.contents).filter(stack -> !stack.isEmpty()).collect(Collectors.toList());
            try {
                methodHandle_addStacks.invoke(probeInfo, world, null, stacks, player.isSneaking());
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
        }
    }
}
Also used : MethodHandle(java.lang.invoke.MethodHandle) Arrays(java.util.Arrays) RebornCoreConfig(reborncore.common.RebornCoreConfig) World(net.minecraft.world.World) IEnergyInterfaceTile(reborncore.api.power.IEnergyInterfaceTile) MethodHandles(java.lang.invoke.MethodHandles) ChestInfoTools(mcjty.theoneprobe.apiimpl.providers.ChestInfoTools) IListInfoProvider(reborncore.api.IListInfoProvider) Inventory(reborncore.common.util.Inventory) BlockPos(net.minecraft.util.math.BlockPos) ProgressStyle(mcjty.theoneprobe.apiimpl.styles.ProgressStyle) TileLegacyMachineBase(reborncore.common.tile.TileLegacyMachineBase) Collectors(java.util.stream.Collectors) I18n(net.minecraft.util.text.translation.I18n) ArrayList(java.util.ArrayList) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) mcjty.theoneprobe.api(mcjty.theoneprobe.api) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PowerSystem(reborncore.common.powerSystem.PowerSystem) TileEntity(net.minecraft.tileentity.TileEntity) Method(java.lang.reflect.Method) ProgressStyle(mcjty.theoneprobe.apiimpl.styles.ProgressStyle) ArrayList(java.util.ArrayList) IEnergyInterfaceTile(reborncore.api.power.IEnergyInterfaceTile) TileEntity(net.minecraft.tileentity.TileEntity) IListInfoProvider(reborncore.api.IListInfoProvider) TileLegacyMachineBase(reborncore.common.tile.TileLegacyMachineBase) ItemStack(net.minecraft.item.ItemStack) Inventory(reborncore.common.util.Inventory)

Example 3 with TileLegacyMachineBase

use of reborncore.common.tile.TileLegacyMachineBase in project RebornCore by TechReborn.

the class PacketIOSave method processData.

@Override
public void processData(PacketIOSave message, MessageContext context) {
    TileLegacyMachineBase legacyMachineBase = (TileLegacyMachineBase) context.getServerHandler().player.world.getTileEntity(pos);
    SlotConfiguration.SlotConfigHolder holder = legacyMachineBase.slotConfiguration.getSlotDetails(slotID);
    if (holder == null) {
        return;
    }
    holder.setInput(input);
    holder.setOutput(output);
    holder.setfilter(filter);
    // Syncs back to the client
    PacketSlotSync packetSlotSync = new PacketSlotSync(pos, legacyMachineBase.slotConfiguration);
    NetworkManager.sendToAll(packetSlotSync);
}
Also used : TileLegacyMachineBase(reborncore.common.tile.TileLegacyMachineBase) SlotConfiguration(reborncore.common.tile.SlotConfiguration)

Example 4 with TileLegacyMachineBase

use of reborncore.common.tile.TileLegacyMachineBase in project RebornCore by TechReborn.

the class PacketSlotSync method processData.

@Override
public void processData(PacketSlotSync message, MessageContext context) {
    if (!RebornCore.proxy.getClientWorld().isBlockLoaded(pos, false)) {
        return;
    }
    TileLegacyMachineBase machineBase = (TileLegacyMachineBase) RebornCore.proxy.getClientWorld().getTileEntity(pos);
    if (machineBase == null || machineBase.slotConfiguration == null || slotConfig == null || slotConfig.getSlotDetails() == null) {
        RebornCore.logHelper.error("Failed to sync slot data to " + pos);
    }
    Minecraft.getMinecraft().addScheduledTask(() -> slotConfig.getSlotDetails().forEach(slotConfigHolder -> machineBase.slotConfiguration.updateSlotDetails(slotConfigHolder)));
}
Also used : SlotConfiguration(reborncore.common.tile.SlotConfiguration) MessageContext(net.minecraftforge.fml.common.network.simpleimpl.MessageContext) ExtendedPacketBuffer(reborncore.common.network.ExtendedPacketBuffer) Minecraft(net.minecraft.client.Minecraft) INetworkPacket(reborncore.common.network.INetworkPacket) BlockPos(net.minecraft.util.math.BlockPos) IOException(java.io.IOException) RebornCore(reborncore.RebornCore) TileLegacyMachineBase(reborncore.common.tile.TileLegacyMachineBase) TileLegacyMachineBase(reborncore.common.tile.TileLegacyMachineBase)

Example 5 with TileLegacyMachineBase

use of reborncore.common.tile.TileLegacyMachineBase in project RebornCore by TechReborn.

the class PacketSlotSave method processData.

@Override
public void processData(PacketSlotSave message, MessageContext context) {
    TileLegacyMachineBase legacyMachineBase = (TileLegacyMachineBase) context.getServerHandler().player.world.getTileEntity(pos);
    legacyMachineBase.slotConfiguration.getSlotDetails(slotConfig.getSlotID()).updateSlotConfig(slotConfig);
    legacyMachineBase.markDirty();
    PacketSlotSync packetSlotSync = new PacketSlotSync(pos, legacyMachineBase.slotConfiguration);
    NetworkManager.sendToWorld(packetSlotSync, legacyMachineBase.getWorld());
}
Also used : TileLegacyMachineBase(reborncore.common.tile.TileLegacyMachineBase)

Aggregations

TileLegacyMachineBase (reborncore.common.tile.TileLegacyMachineBase)5 BlockPos (net.minecraft.util.math.BlockPos)3 IBlockState (net.minecraft.block.state.IBlockState)2 SlotConfiguration (reborncore.common.tile.SlotConfiguration)2 IOException (java.io.IOException)1 MethodHandle (java.lang.invoke.MethodHandle)1 MethodHandles (java.lang.invoke.MethodHandles)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 mcjty.theoneprobe.api (mcjty.theoneprobe.api)1 ChestInfoTools (mcjty.theoneprobe.apiimpl.providers.ChestInfoTools)1 ProgressStyle (mcjty.theoneprobe.apiimpl.styles.ProgressStyle)1 Minecraft (net.minecraft.client.Minecraft)1 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1