Skip to content

Commit

Permalink
Make the ejector component able to handle energy, and make the energy…
Browse files Browse the repository at this point in the history
… cube eject through it. Also, slightly cleanup calls to EnergyDisplay, and rework how the QE handles auto ejecting:

- Eject the entire buffer instead of being limited by the chemical or fluid eject rate
- Try to evenly distribute (except for items) across the different QEs on the frequency instead of just in the order they are ticked. This should help reduce the cases where one QE ends up providing all its energy and the next one that ticks has none to provide; though there are still cases where if a transmitter is set to pull that transmitter may cause other QEs on the same network to get "starved out" depending on the order things tick
  • Loading branch information
pupnewfster committed Nov 14, 2021
1 parent c330ab3 commit d7e9b43
Show file tree
Hide file tree
Showing 21 changed files with 257 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected void addGuiElements() {
if (tile.getMultiblock().isFormed()) {
addButton(new GuiEnergyTab(this, () -> {
FusionReactorMultiblockData multiblock = tile.getMultiblock();
return Arrays.asList(MekanismLang.STORING.translate(EnergyDisplay.of(multiblock.energyContainer.getEnergy(), multiblock.energyContainer.getMaxEnergy())),
return Arrays.asList(MekanismLang.STORING.translate(EnergyDisplay.of(multiblock.energyContainer)),
GeneratorsLang.PRODUCING_AMOUNT.translate(EnergyDisplay.of(multiblock.getPassiveGeneration(false, true))));
}));
addButton(new GuiFusionReactorTab(this, tile, FusionReactorTab.HEAT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiEnergyTab(this, () -> {
FusionReactorMultiblockData multiblock = tile.getMultiblock();
return Arrays.asList(MekanismLang.STORING.translate(EnergyDisplay.of(multiblock.energyContainer.getEnergy(), multiblock.energyContainer.getMaxEnergy())),
return Arrays.asList(MekanismLang.STORING.translate(EnergyDisplay.of(multiblock.energyContainer)),
GeneratorsLang.PRODUCING_AMOUNT.translate(EnergyDisplay.of(multiblock.getPassiveGeneration(false, true))));
}));
addButton(new GuiGasGauge(() -> tile.getMultiblock().deuteriumTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.SMALL, this, 25, 64));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiEnergyTab(this, () -> {
FusionReactorMultiblockData multiblock = tile.getMultiblock();
return Arrays.asList(MekanismLang.STORING.translate(EnergyDisplay.of(multiblock.energyContainer.getEnergy(), multiblock.energyContainer.getMaxEnergy())),
return Arrays.asList(MekanismLang.STORING.translate(EnergyDisplay.of(multiblock.energyContainer)),
GeneratorsLang.PRODUCING_AMOUNT.translate(EnergyDisplay.of(multiblock.getPassiveGeneration(false, true))));
}));
addButton(new GuiNumberGauge(new INumberInfoHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiEnergyTab(this, () -> {
FusionReactorMultiblockData multiblock = tile.getMultiblock();
return Arrays.asList(MekanismLang.STORING.translate(EnergyDisplay.of(multiblock.energyContainer.getEnergy(), multiblock.energyContainer.getMaxEnergy())),
return Arrays.asList(MekanismLang.STORING.translate(EnergyDisplay.of(multiblock.energyContainer)),
GeneratorsLang.PRODUCING_AMOUNT.translate(EnergyDisplay.of(multiblock.getPassiveGeneration(false, true))));
}));
addButton(new GuiFusionReactorTab(this, tile, FusionReactorTab.HEAT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected void addGuiElements() {
public ITextComponent getTooltip() {
TurbineMultiblockData multiblock = tile.getMultiblock();
if (multiblock.isFormed()) {
return EnergyDisplay.of(multiblock.energyContainer.getEnergy(), multiblock.energyContainer.getMaxEnergy()).getTextComponent();
return EnergyDisplay.of(multiblock.energyContainer).getTextComponent();
}
return EnergyDisplay.ZERO.getTextComponent();
}
Expand Down Expand Up @@ -97,7 +97,7 @@ public double getLevel() {
EnergyDisplay producing;
TurbineMultiblockData multiblock = tile.getMultiblock();
if (multiblock.isFormed()) {
storing = EnergyDisplay.of(multiblock.energyContainer.getEnergy(), multiblock.energyContainer.getMaxEnergy());
storing = EnergyDisplay.of(multiblock.energyContainer);
producing = EnergyDisplay.of(MekanismConfig.general.maxEnergyPerSteam.get().divide(TurbineValidator.MAX_BLADES)
.multiply(multiblock.clientFlow * Math.min(multiblock.blades,
multiblock.coils * MekanismGeneratorsConfig.generators.turbineBladesPerCoil.get())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public GuiSolarGenerator(MekanismTileContainer<TILE> container, PlayerInventory
protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiInnerScreen(this, 48, 23, 80, 40, () -> Arrays.asList(
EnergyDisplay.of(tile.getEnergyContainer().getEnergy(), tile.getEnergyContainer().getMaxEnergy()).getTextComponent(),
EnergyDisplay.of(tile.getEnergyContainer()).getTextComponent(),
GeneratorsLang.PRODUCING_AMOUNT.translate(EnergyDisplay.of(tile.getLastProductionAmount())),
GeneratorsLang.OUTPUT_RATE_SHORT.translate(EnergyDisplay.of(tile.getMaxOutput()))
)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected void addGuiElements() {
EnergyDisplay producing;
TurbineMultiblockData multiblock = tile.getMultiblock();
if (multiblock.isFormed()) {
storing = EnergyDisplay.of(multiblock.energyContainer.getEnergy(), multiblock.energyContainer.getMaxEnergy());
storing = EnergyDisplay.of(multiblock.energyContainer);
producing = EnergyDisplay.of(MekanismConfig.general.maxEnergyPerSteam.get().divide(TurbineValidator.MAX_BLADES)
.multiply(multiblock.clientFlow * Math.min(multiblock.blades,
multiblock.coils * MekanismGeneratorsConfig.generators.turbineBladesPerCoil.get())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiInnerScreen(this, 48, 21, 80, 44, () -> {
List<ITextComponent> list = new ArrayList<>();
list.add(EnergyDisplay.of(tile.getEnergyContainer().getEnergy(), tile.getEnergyContainer().getMaxEnergy()).getTextComponent());
list.add(EnergyDisplay.of(tile.getEnergyContainer()).getTextComponent());
list.add(GeneratorsLang.POWER.translate(MekanismUtils.convertToDisplay(MekanismGeneratorsConfig.generators.windGenerationMin.get()
.multiply(tile.getCurrentMultiplier())).toString(2)));
list.add(GeneratorsLang.OUTPUT_RATE_SHORT.translate(EnergyDisplay.of(tile.getMaxOutput())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected IEnergyContainerHolder getInitialEnergyContainers() {
protected void onUpdateServer() {
super.onUpdateServer();
if (MekanismUtils.canFunction(this)) {
//TODO: Cache the directions?
//TODO: Cache the directions or maybe even make some generators have a side config/ejector component and move this to the ejector component?
Set<Direction> emitDirections = EnumSet.noneOf(Direction.class);
Direction direction = getDirection();
for (RelativeSide energySide : getEnergySides()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected void addGuiElements() {
addButton(new GuiFrequencySelector<>(this, 14));
addButton(new GuiEnergyTab(this, () -> {
InventoryFrequency frequency = getFrequency();
EnergyDisplay storing = frequency == null ? EnergyDisplay.ZERO : EnergyDisplay.of(frequency.storedEnergy.getEnergy(), frequency.storedEnergy.getMaxEnergy());
EnergyDisplay storing = frequency == null ? EnergyDisplay.ZERO : EnergyDisplay.of(frequency.storedEnergy);
EnergyDisplay rate = EnergyDisplay.of(tile.getInputRate());
return Arrays.asList(MekanismLang.STORING.translate(storing), MekanismLang.MATRIX_INPUT_RATE.translate(rate));
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public GuiHorizontalPowerBar(IGuiWrapper gui, IEnergyContainer container, int x,
this(gui, new IBarInfoHandler() {
@Override
public ITextComponent getTooltip() {
return EnergyDisplay.of(container.getEnergy(), container.getMaxEnergy()).getTextComponent();
return EnergyDisplay.of(container).getTextComponent();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public GuiVerticalPowerBar(IGuiWrapper gui, IEnergyContainer container, int x, i
this(gui, new IBarInfoHandler() {
@Override
public ITextComponent getTooltip() {
return EnergyDisplay.of(container.getEnergy(), container.getMaxEnergy()).getTextComponent();
return EnergyDisplay.of(container).getTextComponent();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected void addGuiElements() {
@Override
public ITextComponent getTooltip() {
IEnergyContainer container = StorageUtils.getEnergyContainer(menu.getStack(), 0);
return container == null ? EnergyDisplay.ZERO.getTextComponent() : EnergyDisplay.of(container.getEnergy(), container.getMaxEnergy()).getTextComponent();
return container == null ? EnergyDisplay.ZERO.getTextComponent() : EnergyDisplay.of(container).getTextComponent();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiInnerScreen(this, 54, 23, 80, 41, () -> {
List<ITextComponent> list = new ArrayList<>();
list.add(EnergyDisplay.of(tile.getEnergyContainer().getEnergy(), tile.getEnergyContainer().getMaxEnergy()).getTextComponent());
list.add(EnergyDisplay.of(tile.getEnergyContainer()).getTextComponent());
FluidStack fluidStack = tile.fluidTank.getFluid();
if (fluidStack.isEmpty()) {
list.add(MekanismLang.NO_FLUID.translate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiInnerScreen(this, 54, 23, 80, 41, () -> {
List<ITextComponent> list = new ArrayList<>();
list.add(EnergyDisplay.of(tile.getEnergyContainer().getEnergy(), tile.getEnergyContainer().getMaxEnergy()).getTextComponent());
list.add(EnergyDisplay.of(tile.getEnergyContainer()).getTextComponent());
list.add(MekanismLang.FINISHED.translate(YesNo.of(tile.finishedCalc)));
FluidStack fluid = tile.fluidTank.getFluid();
if (fluid.isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mekanism/client/gui/robit/GuiRobitMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void addGuiElements() {
protected void drawForegroundText(@Nonnull MatrixStack matrix, int mouseX, int mouseY) {
drawString(matrix, MekanismLang.ROBIT.translate(), titleLabelX, titleLabelY, titleTextColor());
drawTextScaledBound(matrix, MekanismLang.ROBIT_GREETING.translate(robit.getName()), 29, 18, screenTextColor(), 119);
drawTextScaledBound(matrix, MekanismLang.ENERGY.translate(EnergyDisplay.of(robit.getEnergyContainer().getEnergy(), robit.getEnergyContainer().getMaxEnergy())), 29, 36 - 4, screenTextColor(), 119);
drawTextScaledBound(matrix, MekanismLang.ENERGY.translate(EnergyDisplay.of(robit.getEnergyContainer())), 29, 36 - 4, screenTextColor(), 119);
drawTextScaledBound(matrix, MekanismLang.ROBIT_FOLLOWING.translate(robit.getFollowing()), 29, 45 - 4, screenTextColor(), 119);
drawTextScaledBound(matrix, MekanismLang.ROBIT_DROP_PICKUP.translate(robit.getDropPickup()), 29, 54 - 4, screenTextColor(), 119);
CharSequence owner = robit.getOwnerName().length() > 14 ? robit.getOwnerName().subSequence(0, 14) : robit.getOwnerName();
Expand Down
Loading

0 comments on commit d7e9b43

Please sign in to comment.