Fixes due to PowerAcceptorBE changes.
This commit is contained in:
parent
09d9d6e7ea
commit
df974ef5da
54 changed files with 79 additions and 100 deletions
|
@ -56,6 +56,6 @@ public class DataDrivenGui extends GuiBase<BuiltScreenHandler> {
|
|||
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
||||
|
||||
builder.drawProgressBar(matrixStack, this, blockEntity.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
|
||||
builder.drawMultiEnergyBar(matrixStack, this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
builder.drawMultiEnergyBar(matrixStack, this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxStoredPower(), mouseX, mouseY, 0, layer);
|
||||
}
|
||||
}
|
|
@ -134,12 +134,9 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
|||
}
|
||||
|
||||
protected boolean tryAddingEnergy(int amount) {
|
||||
if (getMaxPower() - getEnergy() >= amount) {
|
||||
if (getFreeSpace() > 0) {
|
||||
addEnergy(amount);
|
||||
return true;
|
||||
} else if (getMaxPower() - getEnergy() > 0) {
|
||||
addEnergy(getMaxPower() - getEnergy());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -233,7 +233,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
|||
.formatted(Formatting.GRAY)
|
||||
.append(": ")
|
||||
.append(
|
||||
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(getMaxPower()))
|
||||
new LiteralText(PowerSystem.getLocaliszedPowerFormatted(getMaxStoredPower()))
|
||||
.formatted(Formatting.GOLD)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -49,13 +49,11 @@ public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
private boolean tryAddingEnergy(int amount) {
|
||||
if (this.getMaxPower() - this.getEnergy() >= amount) {
|
||||
if (getFreeSpace() > 0) {
|
||||
addEnergy(amount);
|
||||
return true;
|
||||
} else if (this.getMaxPower() - this.getEnergy() > 0) {
|
||||
addEnergy(this.getMaxPower() - this.getEnergy());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
|
|||
return;
|
||||
}
|
||||
discharge(1);
|
||||
if (getEnergy() < getMaxPower()) {
|
||||
if (getEnergy() < getMaxStoredPower()) {
|
||||
if (burnTime > 0) {
|
||||
burnTime--;
|
||||
addEnergy(TechRebornConfig.solidFuelGeneratorOutputAmount);
|
||||
|
@ -118,7 +118,7 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
|
|||
final BlockState BlockStateContainer = world.getBlockState(pos);
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
|
||||
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
|
||||
boolean active = burnTime > 0 && getEnergy() < getMaxPower();
|
||||
boolean active = burnTime > 0 && getFreeSpace() > 0.0f;
|
||||
if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != active) {
|
||||
blockMachineBase.setActive(active, world, pos);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import reborncore.common.util.ItemUtils;
|
|||
import reborncore.common.util.RebornInventory;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import reborncore.common.util.Torus;
|
||||
import team.reborn.energy.EnergySide;
|
||||
import techreborn.api.recipe.recipes.FusionReactorRecipe;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
@ -240,7 +241,7 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
|||
|
||||
if (!hasStartedCrafting) {
|
||||
// Ignition!
|
||||
if (canUseEnergy(currentRecipe.getStartEnergy())) {
|
||||
if (getStored(EnergySide.UNKNOWN) > currentRecipe.getStartEnergy()) {
|
||||
useEnergy(currentRecipe.getStartEnergy());
|
||||
hasStartedCrafting = true;
|
||||
useInput(topStackSlot);
|
||||
|
@ -256,7 +257,7 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
|||
powerChange = (power);
|
||||
crafingTickTime++;
|
||||
} else { // Power user
|
||||
if (canUseEnergy(currentRecipe.getPower())) {
|
||||
if (getStored(EnergySide.UNKNOWN) > currentRecipe.getPower()) {
|
||||
setEnergy(getEnergy() - currentRecipe.getPower());
|
||||
crafingTickTime++;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
|||
import reborncore.common.recipes.ExtendedRecipeRemainder;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import team.reborn.energy.EnergySide;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModSounds;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
@ -265,7 +266,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
} else {
|
||||
if (canMake(recipe)) {
|
||||
if (canUseEnergy(euTick)) {
|
||||
if (getStored(EnergySide.UNKNOWN) > euTick) {
|
||||
progress++;
|
||||
if (progress == 1) {
|
||||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.AUTO_CRAFTING,
|
||||
|
|
|
@ -40,6 +40,7 @@ import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
|||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import team.reborn.energy.EnergySide;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.init.TRContent;
|
||||
|
@ -218,7 +219,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
craftRecipe(currentRecipe);
|
||||
updateCurrentRecipe();
|
||||
} else if (cookTime < cookTimeTotal) {
|
||||
if (canUseEnergy(getEuPerTick(EnergyPerTick))) {
|
||||
if (getStored(EnergySide.UNKNOWN) > getEuPerTick(EnergyPerTick)) {
|
||||
useEnergy(getEuPerTick(EnergyPerTick));
|
||||
cookTime++;
|
||||
if (cookTime == 1 || cookTime % 20 == 0 && RecipeCrafter.soundHanlder != null) {
|
||||
|
|
|
@ -41,6 +41,7 @@ import reborncore.common.blockentity.MultiblockWriter;
|
|||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import team.reborn.energy.EnergySide;
|
||||
import techreborn.blocks.lighting.LampBlock;
|
||||
import techreborn.blocks.misc.BlockRubberLog;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
@ -76,7 +77,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
|||
|| block instanceof SugarCaneBlock
|
||||
|| block instanceof CactusBlock
|
||||
) {
|
||||
if (canUseEnergy(TechRebornConfig.greenhouseControllerEnergyPerBonemeal)) {
|
||||
if (getStored(EnergySide.UNKNOWN) > TechRebornConfig.greenhouseControllerEnergyPerBonemeal) {
|
||||
useEnergy(TechRebornConfig.greenhouseControllerEnergyPerBonemeal);
|
||||
blockState.scheduledTick((ServerWorld) world, blockPos, world.random);
|
||||
}
|
||||
|
@ -112,7 +113,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
|||
} else if (block instanceof BlockRubberLog) {
|
||||
for (int y = 0; (blockState = world.getBlockState(blockPos.up(y))).getBlock() == block && y < 10; y++) {
|
||||
if (blockState.get(BlockRubberLog.HAS_SAP)
|
||||
&& canUseEnergy(TechRebornConfig.greenhouseControllerEnergyPerHarvest)
|
||||
&& (getStored(EnergySide.UNKNOWN) > TechRebornConfig.greenhouseControllerEnergyPerHarvest)
|
||||
&& insertIntoInv(Collections.singletonList(TRContent.Parts.SAP.getStack()))
|
||||
) {
|
||||
useEnergy(TechRebornConfig.greenhouseControllerEnergyPerHarvest);
|
||||
|
@ -138,7 +139,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
if (!canUseEnergy(TechRebornConfig.greenhouseControllerEnergyPerHarvest)){
|
||||
if (getStored(EnergySide.UNKNOWN) < TechRebornConfig.greenhouseControllerEnergyPerHarvest){
|
||||
return false;
|
||||
}
|
||||
if (insertIntoInv(Block.getDroppedStacks(blockState, (ServerWorld) world, blockPos, null))) {
|
||||
|
@ -195,7 +196,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
|||
return;
|
||||
}
|
||||
|
||||
if (useEnergy(getEuPerTick(TechRebornConfig.greenhouseControllerEnergyPerTick)) != getEuPerTick(TechRebornConfig.greenhouseControllerEnergyPerTick)) {
|
||||
if (getStored(EnergySide.UNKNOWN) < getEuPerTick(TechRebornConfig.greenhouseControllerEnergyPerTick)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.util.math.Direction;
|
|||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
import team.reborn.energy.EnergySide;
|
||||
import techreborn.blocks.machine.tier1.PlayerDetectorBlock;
|
||||
import techreborn.blocks.machine.tier1.PlayerDetectorBlock.PlayerDetectorType;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
@ -59,7 +60,7 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
|
|||
if (!world.isClient && world.getTime() % 20 == 0) {
|
||||
boolean lastRedstone = redstone;
|
||||
redstone = false;
|
||||
if (canUseEnergy(TechRebornConfig.playerDetectorEuPerTick)) {
|
||||
if (getStored(EnergySide.UNKNOWN) > TechRebornConfig.playerDetectorEuPerTick) {
|
||||
for (PlayerEntity player : world.getPlayers()) {
|
||||
if (player.distanceTo(player) <= 256.0D) {
|
||||
PlayerDetectorType type = world.getBlockState(pos).get(PlayerDetectorBlock.TYPE);
|
||||
|
|
|
@ -40,6 +40,7 @@ import reborncore.common.blockentity.SlotConfiguration;
|
|||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import team.reborn.energy.EnergySide;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.init.TRContent;
|
||||
|
@ -106,7 +107,7 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
|||
final BlockState BlockStateContainer = world.getBlockState(pos);
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
|
||||
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
|
||||
boolean shouldBurn = isBurning || (canRecycle() && canUseEnergy(getEuPerTick(cost)));
|
||||
boolean shouldBurn = isBurning || (canRecycle() && (getStored(EnergySide.UNKNOWN) > getEuPerTick(cost)));
|
||||
if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != shouldBurn) {
|
||||
blockMachineBase.setActive(isBurning, world, pos);
|
||||
}
|
||||
|
@ -126,7 +127,7 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (canRecycle() && !isBurning() && getEnergy() != 0) {
|
||||
setBurning(true);
|
||||
} else if (isBurning()) {
|
||||
if (useEnergy(getEuPerTick(cost)) != getEuPerTick(cost)) {
|
||||
if (getStored(EnergySide.UNKNOWN) < getEuPerTick(cost)) {
|
||||
this.setBurning(false);
|
||||
}
|
||||
progress++;
|
||||
|
|
|
@ -43,6 +43,7 @@ import reborncore.common.blocks.BlockMachineBase;
|
|||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import team.reborn.energy.EnergySide;
|
||||
import techreborn.api.recipe.recipes.RollingMachineRecipe;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
|
@ -160,7 +161,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
tickTime = 0;
|
||||
}
|
||||
if (!currentRecipeOutput.isEmpty()) {
|
||||
if (canUseEnergy(getEuPerTick(TechRebornConfig.rollingMachineEnergyPerTick))
|
||||
if (getStored(EnergySide.UNKNOWN) > getEuPerTick(TechRebornConfig.rollingMachineEnergyPerTick)
|
||||
&& tickTime < Math.max((int) (TechRebornConfig.rollingMachineRunTime * (1.0 - getSpeedMultiplier())), 1)
|
||||
&& canMake(craftMatrix)) {
|
||||
useEnergy(getEuPerTick(TechRebornConfig.rollingMachineEnergyPerTick));
|
||||
|
|
|
@ -35,6 +35,7 @@ import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
|||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import team.reborn.energy.EnergySide;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.init.TRContent;
|
||||
|
@ -134,7 +135,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (!stack.isEmpty() && spaceForOutput()) {
|
||||
final int amp = getValue(stack);
|
||||
final int euNeeded = amp * TechRebornConfig.matterFabricatorEnergyPerAmp;
|
||||
if (amp != 0 && this.canUseEnergy(euNeeded)) {
|
||||
if (amp != 0 && getStored(EnergySide.UNKNOWN) > euNeeded) {
|
||||
useEnergy(euNeeded);
|
||||
amplifier += amp;
|
||||
inventory.shrinkSlot(i, 1);
|
||||
|
|
|
@ -72,13 +72,7 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
|
|||
return;
|
||||
}
|
||||
if (!inventory.getStack(0).isEmpty()) {
|
||||
ItemStack stack = inventory.getStack(0);
|
||||
|
||||
if (Energy.valid(stack)) {
|
||||
Energy.of(this)
|
||||
.into(Energy.of(stack))
|
||||
.move(tier.getMaxInput());
|
||||
}
|
||||
discharge(0);
|
||||
}
|
||||
if (!inventory.getStack(1).isEmpty()) {
|
||||
charge(1);
|
||||
|
|
|
@ -73,9 +73,9 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public double useEnergy(double extract, boolean simulate) {
|
||||
public void useEnergy(double extract) {
|
||||
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
||||
return 0.0;
|
||||
return;
|
||||
}
|
||||
if (world.isClient) {
|
||||
throw new UnsupportedOperationException("cannot set energy on the client!");
|
||||
|
@ -84,21 +84,10 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
|||
if (extract > energy) {
|
||||
extract = energy;
|
||||
}
|
||||
if (!simulate) {
|
||||
setEnergy(energy - extract);
|
||||
}
|
||||
return extract;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUseEnergy(double input) {
|
||||
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (world.isClient) {
|
||||
throw new UnsupportedOperationException("cannot set energy on the client!");
|
||||
}
|
||||
return input <= IDSUManager.getPlayer(world, ownerUdid).getEnergy();
|
||||
setStored(energy - extract);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,7 +114,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldHanldeEnergyNBT() {
|
||||
protected boolean shouldHandleEnergyNBT() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,8 +73,6 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
|||
this.maxOutput = tier.getMaxOutput();
|
||||
this.maxStorage = tier.getMaxInput() * 2;
|
||||
|
||||
// Should always be 4, except if we're tier MICRO, in which it will be 1.
|
||||
super.setMaxPacketsPerTick(tier.getMaxOutput() / ouputTier.getMaxInput());
|
||||
}
|
||||
|
||||
// TilePowerAcceptor
|
||||
|
@ -109,11 +107,6 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
|||
return inputTier.getMaxInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnergyTier getPushingTier() {
|
||||
return ouputTier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkTier() {
|
||||
//Nope
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue