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))));
}
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;
}
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));
}
}
}
Aggregations