Search in sources :

Example 1 with SPSMultiblockData

use of mekanism.common.content.sps.SPSMultiblockData in project Mekanism by mekanism.

the class GuiSPS method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiGasGauge(() -> tile.getMultiblock().inputTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 7, 17));
    addButton(new GuiGasGauge(() -> tile.getMultiblock().outputTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 151, 17));
    addButton(new GuiInnerScreen(this, 27, 17, 122, 60, () -> {
        List<ITextComponent> list = new ArrayList<>();
        SPSMultiblockData multiblock = tile.getMultiblock();
        boolean active = multiblock.lastProcessed > 0;
        list.add(MekanismLang.STATUS.translate(active ? MekanismLang.ACTIVE : MekanismLang.IDLE));
        if (active) {
            list.add(MekanismLang.SPS_ENERGY_INPUT.translate(EnergyDisplay.of(multiblock.lastReceivedEnergy)));
            list.add(MekanismLang.PROCESS_RATE_MB.translate(multiblock.getProcessRate()));
        }
        return list;
    }).jeiCategories(MekanismBlocks.SPS_CASING.getRegistryName()));
    addButton(new GuiDynamicHorizontalRateBar(this, new IBarInfoHandler() {

        @Override
        public ITextComponent getTooltip() {
            return MekanismLang.PROGRESS.translate(TextUtils.getPercent(tile.getMultiblock().getScaledProgress()));
        }

        @Override
        public double getLevel() {
            return Math.min(1, tile.getMultiblock().getScaledProgress());
        }
    }, 7, 79, 160, ColorFunction.scale(Color.rgbi(60, 45, 74), Color.rgbi(100, 30, 170))));
}
Also used : GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) IBarInfoHandler(mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler) GuiGasGauge(mekanism.client.gui.element.gauge.GuiGasGauge) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) GuiDynamicHorizontalRateBar(mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar) SPSMultiblockData(mekanism.common.content.sps.SPSMultiblockData)

Example 2 with SPSMultiblockData

use of mekanism.common.content.sps.SPSMultiblockData in project Mekanism by mekanism.

the class TileEntitySPSCasing method getReducedUpdateTag.

@Nonnull
@Override
public CompoundNBT getReducedUpdateTag() {
    CompoundNBT updateTag = super.getReducedUpdateTag();
    SPSMultiblockData multiblock = getMultiblock();
    updateTag.putBoolean(NBTConstants.HANDLE_SOUND, multiblock.isFormed() && multiblock.handlesSound(this) && multiblock.lastProcessed > 0);
    return updateTag;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) SPSMultiblockData(mekanism.common.content.sps.SPSMultiblockData) Nonnull(javax.annotation.Nonnull)

Example 3 with SPSMultiblockData

use of mekanism.common.content.sps.SPSMultiblockData in project Mekanism by mekanism.

the class RenderSPS method render.

@Override
protected void render(TileEntitySPSCasing tile, float partialTick, MatrixStack matrix, IRenderTypeBuffer renderer, int light, int overlayLight, IProfiler profiler) {
    if (tile.isMaster()) {
        SPSMultiblockData multiblock = tile.getMultiblock();
        if (multiblock.isFormed() && multiblock.renderLocation != null && multiblock.getBounds() != null) {
            BoltRenderer bolts = boltRendererMap.computeIfAbsent(multiblock.inventoryID, mb -> new BoltRenderer());
            Vector3d center = Vector3d.atLowerCornerOf(multiblock.getMinPos()).add(Vector3d.atLowerCornerOf(multiblock.getMaxPos())).add(new Vector3d(1, 1, 1)).scale(0.5);
            Vector3d renderCenter = center.subtract(tile.getBlockPos().getX(), tile.getBlockPos().getY(), tile.getBlockPos().getZ());
            if (!minecraft.isPaused()) {
                for (CoilData data : multiblock.coilData.coilMap.values()) {
                    if (data.prevLevel > 0) {
                        bolts.update(data.coilPos.hashCode(), getBoltFromData(data, tile.getBlockPos(), multiblock, renderCenter), partialTick);
                    }
                }
            }
            float energyScale = getEnergyScale(multiblock.lastProcessed);
            int targetEffectCount = 0;
            if (!minecraft.isPaused() && !multiblock.lastReceivedEnergy.isZero()) {
                if (rand.nextDouble() < getBoundedScale(energyScale, 0.01F, 0.4F)) {
                    CuboidSide side = CuboidSide.SIDES[rand.nextInt(6)];
                    Plane plane = Plane.getInnerCuboidPlane(multiblock.getBounds(), side);
                    Vector3d endPos = plane.getRandomPoint(rand).subtract(tile.getBlockPos().getX(), tile.getBlockPos().getY(), tile.getBlockPos().getZ());
                    BoltEffect bolt = new BoltEffect(BoltRenderInfo.ELECTRICITY, renderCenter, endPos, 15).size(0.01F * getBoundedScale(energyScale, 0.5F, 5)).lifespan(8).spawn(SpawnFunction.NO_DELAY);
                    bolts.update(Objects.hash(side, endPos), bolt, partialTick);
                }
                targetEffectCount = (int) getBoundedScale(energyScale, 10, 120);
            }
            if (tile.orbitEffects.size() > targetEffectCount) {
                tile.orbitEffects.poll();
            } else if (tile.orbitEffects.size() < targetEffectCount && rand.nextDouble() < 0.5) {
                tile.orbitEffects.add(new SPSOrbitEffect(multiblock, center));
            }
            bolts.render(partialTick, matrix, renderer);
            if (multiblock.lastProcessed > 0) {
                CORE.setPos(center);
                CORE.setScale(getBoundedScale(energyScale, MIN_SCALE, MAX_SCALE));
                BillboardingEffectRenderer.render(CORE, tile.getBlockPos(), matrix, renderer, tile.getLevel().getGameTime(), partialTick);
            }
            tile.orbitEffects.forEach(effect -> BillboardingEffectRenderer.render(effect, tile.getBlockPos(), matrix, renderer, tile.getLevel().getGameTime(), partialTick));
        }
    }
}
Also used : SPSOrbitEffect(mekanism.common.particle.SPSOrbitEffect) Vector3d(net.minecraft.util.math.vector.Vector3d) Plane(mekanism.common.lib.math.Plane) BoltRenderer(mekanism.client.render.lib.effect.BoltRenderer) CoilData(mekanism.common.content.sps.SPSMultiblockData.CoilData) SPSMultiblockData(mekanism.common.content.sps.SPSMultiblockData) CuboidSide(mekanism.common.lib.math.voxel.VoxelCuboid.CuboidSide) BoltEffect(mekanism.common.lib.effect.BoltEffect)

Aggregations

SPSMultiblockData (mekanism.common.content.sps.SPSMultiblockData)3 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 GuiInnerScreen (mekanism.client.gui.element.GuiInnerScreen)1 IBarInfoHandler (mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler)1 GuiDynamicHorizontalRateBar (mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar)1 GuiGasGauge (mekanism.client.gui.element.gauge.GuiGasGauge)1 BoltRenderer (mekanism.client.render.lib.effect.BoltRenderer)1 CoilData (mekanism.common.content.sps.SPSMultiblockData.CoilData)1 BoltEffect (mekanism.common.lib.effect.BoltEffect)1 Plane (mekanism.common.lib.math.Plane)1 CuboidSide (mekanism.common.lib.math.voxel.VoxelCuboid.CuboidSide)1 SPSOrbitEffect (mekanism.common.particle.SPSOrbitEffect)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 Vector3d (net.minecraft.util.math.vector.Vector3d)1 ITextComponent (net.minecraft.util.text.ITextComponent)1