Move most int fluid values to FluidValue.
This has been done to make it easier in the future to move to a new fluid system. Some work is still needed (in recipes mainly) to move away fully away from mb. This should work identically to the old system for now.
This commit is contained in:
parent
2fe94ddbf0
commit
5e5e997b93
19 changed files with 125 additions and 130 deletions
|
@ -43,8 +43,8 @@ public class FluidGeneratorRecipe {
|
||||||
return fluid;
|
return fluid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEnergyPerMb() {
|
public int getEnergyPerBucket() {
|
||||||
return energyPerMb;
|
return energyPerMb * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EFluidGenerator getGeneratorType() {
|
public EFluidGenerator getGeneratorType() {
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.commons.lang3.Validate;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import reborncore.common.fluid.container.FluidInstance;
|
import reborncore.common.fluid.container.FluidInstance;
|
||||||
import reborncore.common.fluid.container.ItemFluidInfo;
|
import reborncore.common.fluid.container.ItemFluidInfo;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
|
@ -62,7 +63,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
||||||
*/
|
*/
|
||||||
double pendingWithdraw = 0.0;
|
double pendingWithdraw = 0.0;
|
||||||
|
|
||||||
public BaseFluidGeneratorBlockEntity(BlockEntityType<?> blockEntityType, EFluidGenerator type, String blockEntityName, int tankCapacity, int euTick) {
|
public BaseFluidGeneratorBlockEntity(BlockEntityType<?> blockEntityType, EFluidGenerator type, String blockEntityName, FluidValue tankCapacity, int euTick) {
|
||||||
super(blockEntityType);
|
super(blockEntityType);
|
||||||
recipes = GeneratorRecipeHelper.getFluidRecipesForGenerator(type);
|
recipes = GeneratorRecipeHelper.getFluidRecipesForGenerator(type);
|
||||||
Validate.notNull(recipes, "null recipe list for " + type.getRecipeID());
|
Validate.notNull(recipes, "null recipe list for " + type.getRecipeID());
|
||||||
|
@ -85,7 +86,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
||||||
if (ticksSinceLastChange >= 10) {
|
if (ticksSinceLastChange >= 10) {
|
||||||
ItemStack inputStack = inventory.getInvStack(0);
|
ItemStack inputStack = inventory.getInvStack(0);
|
||||||
if (!inputStack.isEmpty()) {
|
if (!inputStack.isEmpty()) {
|
||||||
if (FluidUtils.isContainerEmpty(inputStack) && tank.getFluidAmount() > 0) {
|
if (FluidUtils.isContainerEmpty(inputStack) && !tank.getFluidAmount().isEmpty()) {
|
||||||
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid());
|
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid());
|
||||||
}
|
}
|
||||||
else if (inputStack.getItem() instanceof ItemFluidInfo && getRecipes().getRecipeForFluid(((ItemFluidInfo) inputStack.getItem()).getFluid(inputStack)).isPresent()) {
|
else if (inputStack.getItem() instanceof ItemFluidInfo && getRecipes().getRecipeForFluid(((ItemFluidInfo) inputStack.getItem()).getFluid(inputStack)).isPresent()) {
|
||||||
|
@ -96,19 +97,19 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
||||||
ticksSinceLastChange = 0;
|
ticksSinceLastChange = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tank.getFluidAmount() > 0) {
|
if (!tank.getFluidAmount().isEmpty()) {
|
||||||
if (currentRecipe == null || !FluidUtils.fluidEquals(currentRecipe.getFluid(), tank.getFluid()))
|
if (currentRecipe == null || !FluidUtils.fluidEquals(currentRecipe.getFluid(), tank.getFluid()))
|
||||||
currentRecipe = getRecipes().getRecipeForFluid(tank.getFluid()).orElse(null);
|
currentRecipe = getRecipes().getRecipeForFluid(tank.getFluid()).orElse(null);
|
||||||
|
|
||||||
if (currentRecipe != null) {
|
if (currentRecipe != null) {
|
||||||
final Integer euPerBucket = currentRecipe.getEnergyPerMb() * 1000;
|
final int euPerBucket = currentRecipe.getEnergyPerBucket();
|
||||||
final float millibucketsPerTick = euTick * 1000 / (float) euPerBucket;
|
final float millibucketsPerTick = euTick * 1000 / (float) euPerBucket;
|
||||||
|
|
||||||
if (tryAddingEnergy(euTick)) {
|
if (tryAddingEnergy(euTick)) {
|
||||||
pendingWithdraw += millibucketsPerTick;
|
pendingWithdraw += millibucketsPerTick;
|
||||||
final int currentWithdraw = (int) pendingWithdraw;
|
final int currentWithdraw = (int) pendingWithdraw;
|
||||||
pendingWithdraw -= currentWithdraw;
|
pendingWithdraw -= currentWithdraw;
|
||||||
tank.getFluidInstance().subtractAmount(currentWithdraw);
|
tank.getFluidInstance().subtractAmount(FluidValue.fromRaw(currentWithdraw));
|
||||||
lastOutput = world.getTime();
|
lastOutput = world.getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,11 +206,11 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
||||||
this.ticksSinceLastChange = ticksSinceLastChange;
|
this.ticksSinceLastChange = ticksSinceLastChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTankAmount(){
|
public FluidValue getTankAmount(){
|
||||||
return tank.getFluidAmount();
|
return tank.getFluidAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTankAmount(int amount){
|
public void setTankAmount(FluidValue amount){
|
||||||
tank.setFluidAmount(amount);
|
tank.setFluidAmount(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import reborncore.client.containerBuilder.IContainerProvider;
|
import reborncore.client.containerBuilder.IContainerProvider;
|
||||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import techreborn.api.generator.EFluidGenerator;
|
import techreborn.api.generator.EFluidGenerator;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
|
@ -37,7 +38,7 @@ import techreborn.init.TRContent;
|
||||||
public class PlasmaGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
public class PlasmaGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||||
|
|
||||||
public PlasmaGeneratorBlockEntity() {
|
public PlasmaGeneratorBlockEntity() {
|
||||||
super(TRBlockEntities.PLASMA_GENERATOR, EFluidGenerator.PLASMA, "PlasmaGeneratorBlockEntity", TechRebornConfig.plasmaGeneratorTankCapacity, TechRebornConfig.plasmaGeneratorEnergyPerTick);
|
super(TRBlockEntities.PLASMA_GENERATOR, EFluidGenerator.PLASMA, "PlasmaGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.plasmaGeneratorEnergyPerTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import reborncore.client.containerBuilder.IContainerProvider;
|
import reborncore.client.containerBuilder.IContainerProvider;
|
||||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import techreborn.api.generator.EFluidGenerator;
|
import techreborn.api.generator.EFluidGenerator;
|
||||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -38,7 +39,7 @@ import techreborn.init.TRContent;
|
||||||
public class DieselGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
public class DieselGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||||
|
|
||||||
public DieselGeneratorBlockEntity() {
|
public DieselGeneratorBlockEntity() {
|
||||||
super(TRBlockEntities.DIESEL_GENERATOR, EFluidGenerator.DIESEL, "DieselGeneratorBlockEntity", TechRebornConfig.dieselGeneratorTankCapacity, TechRebornConfig.dieselGeneratorEnergyPerTick);
|
super(TRBlockEntities.DIESEL_GENERATOR, EFluidGenerator.DIESEL, "DieselGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.dieselGeneratorEnergyPerTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import reborncore.client.containerBuilder.IContainerProvider;
|
import reborncore.client.containerBuilder.IContainerProvider;
|
||||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import techreborn.api.generator.EFluidGenerator;
|
import techreborn.api.generator.EFluidGenerator;
|
||||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -38,7 +39,7 @@ import techreborn.init.TRContent;
|
||||||
public class GasTurbineBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
public class GasTurbineBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||||
|
|
||||||
public GasTurbineBlockEntity() {
|
public GasTurbineBlockEntity() {
|
||||||
super(TRBlockEntities.GAS_TURBINE, EFluidGenerator.GAS, "GasTurbineBlockEntity", TechRebornConfig.gasTurbineTankCapacity, TechRebornConfig.gasTurbineEnergyPerTick);
|
super(TRBlockEntities.GAS_TURBINE, EFluidGenerator.GAS, "GasTurbineBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.gasTurbineEnergyPerTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import reborncore.client.containerBuilder.IContainerProvider;
|
import reborncore.client.containerBuilder.IContainerProvider;
|
||||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import techreborn.api.generator.EFluidGenerator;
|
import techreborn.api.generator.EFluidGenerator;
|
||||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -38,7 +39,7 @@ import techreborn.init.TRContent;
|
||||||
public class SemiFluidGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
public class SemiFluidGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||||
|
|
||||||
public SemiFluidGeneratorBlockEntity() {
|
public SemiFluidGeneratorBlockEntity() {
|
||||||
super(TRBlockEntities.SEMI_FLUID_GENERATOR, EFluidGenerator.SEMIFLUID, "SemiFluidGeneratorBlockEntity", TechRebornConfig.semiFluidGeneratorTankCapacity, TechRebornConfig.semiFluidGeneratorEnergyPerTick);
|
super(TRBlockEntities.SEMI_FLUID_GENERATOR, EFluidGenerator.SEMIFLUID, "SemiFluidGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.semiFluidGeneratorEnergyPerTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import reborncore.client.containerBuilder.IContainerProvider;
|
import reborncore.client.containerBuilder.IContainerProvider;
|
||||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import techreborn.api.generator.EFluidGenerator;
|
import techreborn.api.generator.EFluidGenerator;
|
||||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -38,7 +39,7 @@ import techreborn.init.TRContent;
|
||||||
public class ThermalGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
public class ThermalGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||||
|
|
||||||
public ThermalGeneratorBlockEntity() {
|
public ThermalGeneratorBlockEntity() {
|
||||||
super(TRBlockEntities.THERMAL_GEN, EFluidGenerator.THERMAL, "ThermalGeneratorBlockEntity", TechRebornConfig.thermalGeneratorTankCapacity, TechRebornConfig.thermalGeneratorEnergyPerTick);
|
super(TRBlockEntities.THERMAL_GEN, EFluidGenerator.THERMAL, "ThermalGeneratorBlockEntity", FluidValue.BUCKET.multiply(10), TechRebornConfig.thermalGeneratorEnergyPerTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,6 +30,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import reborncore.client.containerBuilder.IContainerProvider;
|
import reborncore.client.containerBuilder.IContainerProvider;
|
||||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.IInventoryAccess;
|
import reborncore.common.util.IInventoryAccess;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
|
@ -50,7 +51,7 @@ import javax.annotation.Nullable;
|
||||||
public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implements IContainerProvider {
|
public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implements IContainerProvider {
|
||||||
|
|
||||||
public MultiblockChecker multiblockChecker;
|
public MultiblockChecker multiblockChecker;
|
||||||
public static final int TANK_CAPACITY = 16_000;
|
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
|
||||||
public Tank tank;
|
public Tank tank;
|
||||||
int ticksSinceLastChange;
|
int ticksSinceLastChange;
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import net.minecraft.util.math.Direction;
|
||||||
import reborncore.client.containerBuilder.IContainerProvider;
|
import reborncore.client.containerBuilder.IContainerProvider;
|
||||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import reborncore.common.util.Tank;
|
import reborncore.common.util.Tank;
|
||||||
|
@ -48,7 +49,7 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity implements IContainerProvider{
|
public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity implements IContainerProvider{
|
||||||
|
|
||||||
public static final int TANK_CAPACITY = 16_000;
|
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
|
||||||
public Tank tank;
|
public Tank tank;
|
||||||
public MultiblockChecker multiblockChecker;
|
public MultiblockChecker multiblockChecker;
|
||||||
int ticksSinceLastChange;
|
int ticksSinceLastChange;
|
||||||
|
|
|
@ -34,6 +34,7 @@ import net.minecraft.util.math.Direction;
|
||||||
import reborncore.client.containerBuilder.IContainerProvider;
|
import reborncore.client.containerBuilder.IContainerProvider;
|
||||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import reborncore.common.util.Tank;
|
import reborncore.common.util.Tank;
|
||||||
|
@ -48,7 +49,7 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity implements IContainerProvider {
|
public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity implements IContainerProvider {
|
||||||
|
|
||||||
public static final int TANK_CAPACITY = 16_000;
|
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
|
||||||
public Tank tank;
|
public Tank tank;
|
||||||
public MultiblockChecker multiblockChecker;
|
public MultiblockChecker multiblockChecker;
|
||||||
int ticksSinceLastChange;
|
int ticksSinceLastChange;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
package techreborn.blockentity.machine.tier3;
|
package techreborn.blockentity.machine.tier3;
|
||||||
|
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
|
|
||||||
public class CreativeQuantumTankBlockEntity extends QuantumTankBlockEntity {
|
public class CreativeQuantumTankBlockEntity extends QuantumTankBlockEntity {
|
||||||
|
@ -36,7 +37,7 @@ public class CreativeQuantumTankBlockEntity extends QuantumTankBlockEntity {
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if (!tank.isEmpty() && !tank.isFull()) {
|
if (!tank.isEmpty() && !tank.isFull()) {
|
||||||
tank.setFluidAmount(Integer.MAX_VALUE);
|
tank.setFluidAmount(FluidValue.INFINITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ import reborncore.client.containerBuilder.IContainerProvider;
|
||||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import reborncore.common.util.Tank;
|
import reborncore.common.util.Tank;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -50,7 +51,7 @@ import java.util.List;
|
||||||
public class QuantumTankBlockEntity extends MachineBaseBlockEntity
|
public class QuantumTankBlockEntity extends MachineBaseBlockEntity
|
||||||
implements InventoryProvider, IToolDrop, IListInfoProvider, IContainerProvider {
|
implements InventoryProvider, IToolDrop, IListInfoProvider, IContainerProvider {
|
||||||
|
|
||||||
public Tank tank = new Tank("QuantumTankBlockEntity", TechRebornConfig.quantumTankMaxStorage, this);
|
public Tank tank = new Tank("QuantumTankBlockEntity", FluidValue.INFINITE, this);
|
||||||
public RebornInventory<QuantumTankBlockEntity> inventory = new RebornInventory<>(3, "QuantumTankBlockEntity", 64, this);
|
public RebornInventory<QuantumTankBlockEntity> inventory = new RebornInventory<>(3, "QuantumTankBlockEntity", 64, this);
|
||||||
|
|
||||||
public QuantumTankBlockEntity(){
|
public QuantumTankBlockEntity(){
|
||||||
|
@ -132,7 +133,7 @@ public class QuantumTankBlockEntity extends MachineBaseBlockEntity
|
||||||
info.add(new LiteralText("Empty"));
|
info.add(new LiteralText("Empty"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.add(new LiteralText("Capacity " + this.tank.getCapacity() + " mb"));
|
info.add(new LiteralText("Capacity " + this.tank.getCapacity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// IContainerProvider
|
// IContainerProvider
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class GuiQuantumTank extends GuiBase<BuiltContainer> {
|
||||||
font.draw(FluidUtil.getFluidName(fluid) + "", 10, 30, 4210752);
|
font.draw(FluidUtil.getFluidName(fluid) + "", 10, 30, 4210752);
|
||||||
|
|
||||||
font.draw("Fluid Amount:", 10, 50, 4210752);
|
font.draw("Fluid Amount:", 10, 50, 4210752);
|
||||||
font.draw(quantumTank.tank.getFluidAmount() + "mb", 10, 60, 4210752);
|
font.draw(quantumTank.tank.getFluidAmount().toString() , 10, 60, 4210752);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.tag.Tag;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import reborncore.common.crafting.ingredient.*;
|
import reborncore.common.crafting.ingredient.*;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import reborncore.common.fluid.container.FluidInstance;
|
import reborncore.common.fluid.container.FluidInstance;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -97,6 +98,6 @@ public class TRRecipeParser {
|
||||||
amount = Integer.parseInt(amtStr);
|
amount = Integer.parseInt(amtStr);
|
||||||
}
|
}
|
||||||
Identifier id = new Identifier(fluid);
|
Identifier id = new Identifier(fluid);
|
||||||
return new FluidInstance(Registry.FLUID.get(id), amount);
|
return new FluidInstance(Registry.FLUID.get(id), FluidValue.fromRaw(amount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class TRTweaker implements Tweaker {
|
||||||
JsonArray array = (JsonArray) debug.get(genID);
|
JsonArray array = (JsonArray) debug.get(genID);
|
||||||
JsonObject recipeInfo = new JsonObject();
|
JsonObject recipeInfo = new JsonObject();
|
||||||
recipeInfo.put("fluid", new JsonPrimitive(Registry.FLUID.getId(recipe.getFluid()).toString()));
|
recipeInfo.put("fluid", new JsonPrimitive(Registry.FLUID.getId(recipe.getFluid()).toString()));
|
||||||
recipeInfo.put("energy_per_mb", new JsonPrimitive(recipe.getEnergyPerMb()));
|
recipeInfo.put("energy_per_mb", new JsonPrimitive(recipe.getEnergyPerBucket() / 1000));
|
||||||
array.add(recipeInfo);
|
array.add(recipeInfo);
|
||||||
} else {
|
} else {
|
||||||
tweaker.getLogger().error("Could not add recipe to TechReborn generator " + recipe.getGeneratorType().getRecipeID()
|
tweaker.getLogger().error("Could not add recipe to TechReborn generator " + recipe.getGeneratorType().getRecipeID()
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
|
||||||
}
|
}
|
||||||
if (recipe instanceof RebornFluidRecipe) {
|
if (recipe instanceof RebornFluidRecipe) {
|
||||||
this.fluidInstance = ((RebornFluidRecipe) recipe).getFluidInstance();
|
this.fluidInstance = ((RebornFluidRecipe) recipe).getFluidInstance();
|
||||||
inputs.add(Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount())));
|
inputs.add(Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), EntryStack::create));
|
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), EntryStack::create));
|
||||||
this.fluidInstance = recipe.getFluidInstance();
|
this.fluidInstance = recipe.getFluidInstance();
|
||||||
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount()));
|
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue()));
|
||||||
this.energy = recipe.getPower();
|
this.energy = recipe.getPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,6 @@ public class TechRebornConfig {
|
||||||
@Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorMaxEnergy", comment = "Thermal Generator Max Energy (Value in EU)")
|
@Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorMaxEnergy", comment = "Thermal Generator Max Energy (Value in EU)")
|
||||||
public static int thermalGeneratorMaxEnergy = 1_000_000;
|
public static int thermalGeneratorMaxEnergy = 1_000_000;
|
||||||
|
|
||||||
@Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorTankCapacity", comment = "Thermal Generator Tank Capacity")
|
|
||||||
public static int thermalGeneratorTankCapacity = 10_000;
|
|
||||||
|
|
||||||
@Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorEnergyPerTick", comment = "Thermal Generator Energy Per Tick (Value in EU)")
|
@Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorEnergyPerTick", comment = "Thermal Generator Energy Per Tick (Value in EU)")
|
||||||
public static int thermalGeneratorEnergyPerTick = 16;
|
public static int thermalGeneratorEnergyPerTick = 16;
|
||||||
|
|
||||||
|
@ -90,9 +87,6 @@ public class TechRebornConfig {
|
||||||
@Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorMaxEnergy", comment = "Plasma Generator Max Energy (Value in EU)")
|
@Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorMaxEnergy", comment = "Plasma Generator Max Energy (Value in EU)")
|
||||||
public static double plasmaGeneratorMaxEnergy = 500_000_000;
|
public static double plasmaGeneratorMaxEnergy = 500_000_000;
|
||||||
|
|
||||||
@Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorTankCapacity", comment = "Plasma Generator Tank Capacity")
|
|
||||||
public static int plasmaGeneratorTankCapacity = 10_000;
|
|
||||||
|
|
||||||
@Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorEnergyPerTick", comment = "Plasma Generator Energy Per Tick (Value in EU)")
|
@Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorEnergyPerTick", comment = "Plasma Generator Energy Per Tick (Value in EU)")
|
||||||
public static int plasmaGeneratorEnergyPerTick = 400;
|
public static int plasmaGeneratorEnergyPerTick = 400;
|
||||||
|
|
||||||
|
@ -123,9 +117,6 @@ public class TechRebornConfig {
|
||||||
@Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorMaxEnergy", comment = "Semifluid Generator Max Energy (Value in EU)")
|
@Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorMaxEnergy", comment = "Semifluid Generator Max Energy (Value in EU)")
|
||||||
public static int semiFluidGeneratorMaxEnergy = 1000000;
|
public static int semiFluidGeneratorMaxEnergy = 1000000;
|
||||||
|
|
||||||
@Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorTankCapacity", comment = "Semifluid Generator Tank Capacity")
|
|
||||||
public static int semiFluidGeneratorTankCapacity = 10000;
|
|
||||||
|
|
||||||
@Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorEnergyPerTick", comment = "Semifluid Generator Energy Per Tick (Value in EU)")
|
@Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorEnergyPerTick", comment = "Semifluid Generator Energy Per Tick (Value in EU)")
|
||||||
public static int semiFluidGeneratorEnergyPerTick = 8;
|
public static int semiFluidGeneratorEnergyPerTick = 8;
|
||||||
|
|
||||||
|
@ -135,9 +126,6 @@ public class TechRebornConfig {
|
||||||
@Config(config = "generators", category = "gas_generator", key = "GasGeneratorMaxEnergy", comment = "Gas Generator Max Energy (Value in EU)")
|
@Config(config = "generators", category = "gas_generator", key = "GasGeneratorMaxEnergy", comment = "Gas Generator Max Energy (Value in EU)")
|
||||||
public static int gasTurbineMaxEnergy = 1000000;
|
public static int gasTurbineMaxEnergy = 1000000;
|
||||||
|
|
||||||
@Config(config = "generators", category = "gas_generator", key = "GasGeneratorTankCapacity", comment = "Gas Generator Tank Capacity")
|
|
||||||
public static int gasTurbineTankCapacity = 10000;
|
|
||||||
|
|
||||||
@Config(config = "generators", category = "gas_generator", key = "GasGeneratorEnergyPerTick", comment = "Gas Generator Energy Per Tick (Value in EU)")
|
@Config(config = "generators", category = "gas_generator", key = "GasGeneratorEnergyPerTick", comment = "Gas Generator Energy Per Tick (Value in EU)")
|
||||||
public static int gasTurbineEnergyPerTick = 16;
|
public static int gasTurbineEnergyPerTick = 16;
|
||||||
|
|
||||||
|
@ -147,9 +135,6 @@ public class TechRebornConfig {
|
||||||
@Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorMaxEnergy", comment = "Diesel Generator Max Energy (Value in EU)")
|
@Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorMaxEnergy", comment = "Diesel Generator Max Energy (Value in EU)")
|
||||||
public static int dieselGeneratorMaxEnergy = 10_000;
|
public static int dieselGeneratorMaxEnergy = 10_000;
|
||||||
|
|
||||||
@Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorTankCapacity", comment = "Diesel Generator Tank Capacity")
|
|
||||||
public static int dieselGeneratorTankCapacity = 10_000;
|
|
||||||
|
|
||||||
@Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorEnergyPerTick", comment = "Diesel Generator Energy Per Tick (Value in EU)")
|
@Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorEnergyPerTick", comment = "Diesel Generator Energy Per Tick (Value in EU)")
|
||||||
public static int dieselGeneratorEnergyPerTick = 20;
|
public static int dieselGeneratorEnergyPerTick = 20;
|
||||||
|
|
||||||
|
@ -383,9 +368,6 @@ public class TechRebornConfig {
|
||||||
@Config(config = "machines", category = "electric_furnace", key = "ElectricFurnaceMaxEnergy", comment = "Electric Furnace Max Energy (Value in EU)")
|
@Config(config = "machines", category = "electric_furnace", key = "ElectricFurnaceMaxEnergy", comment = "Electric Furnace Max Energy (Value in EU)")
|
||||||
public static int electricFurnaceMaxEnergy = 1000;
|
public static int electricFurnaceMaxEnergy = 1000;
|
||||||
|
|
||||||
@Config(config = "machines", category = "quantum_tank", key = "QuantumTankMaxStorage", comment = "Maximum amount of millibuckets a Quantum Tank can store")
|
|
||||||
public static int quantumTankMaxStorage = Integer.MAX_VALUE;
|
|
||||||
|
|
||||||
@Config(config = "machines", category = "digital_chest", key = "DigitalChestMaxStorage", comment = "Maximum amount of items a Digital Chest can store")
|
@Config(config = "machines", category = "digital_chest", key = "DigitalChestMaxStorage", comment = "Maximum amount of items a Digital Chest can store")
|
||||||
public static int digitalChestMaxStorage = 32768;
|
public static int digitalChestMaxStorage = 32768;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import reborncore.common.fluid.FluidValue;
|
||||||
import reborncore.common.fluid.container.FluidInstance;
|
import reborncore.common.fluid.container.FluidInstance;
|
||||||
import reborncore.common.fluid.container.GenericFluidContainer;
|
import reborncore.common.fluid.container.GenericFluidContainer;
|
||||||
import reborncore.common.fluid.container.ItemFluidInfo;
|
import reborncore.common.fluid.container.ItemFluidInfo;
|
||||||
|
@ -67,7 +68,7 @@ public class FluidUtils {
|
||||||
Fluid currentFluid = targetFluidInstance.getFluid();
|
Fluid currentFluid = targetFluidInstance.getFluid();
|
||||||
|
|
||||||
if(targetFluidInstance.isEmpty() || currentFluid == itemFluidInfo.getFluid(inputStack)) {
|
if(targetFluidInstance.isEmpty() || currentFluid == itemFluidInfo.getFluid(inputStack)) {
|
||||||
int freeSpace = target.getCapacity(null) - targetFluidInstance.getAmount();
|
FluidValue freeSpace = target.getCapacity(null).subtract(targetFluidInstance.getAmount());
|
||||||
|
|
||||||
if(!outputStack.isEmpty()){
|
if(!outputStack.isEmpty()){
|
||||||
if(outputStack.getCount() + 1 >= outputStack.getMaxCount()){
|
if(outputStack.getCount() + 1 >= outputStack.getMaxCount()){
|
||||||
|
@ -75,10 +76,10 @@ public class FluidUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(freeSpace >= 1000){
|
if(freeSpace.equalOrMoreThan(FluidValue.BUCKET)){
|
||||||
inputStack.decrement(1);
|
inputStack.decrement(1);
|
||||||
targetFluidInstance.setFluid(itemFluidInfo.getFluid(inputStack));
|
targetFluidInstance.setFluid(itemFluidInfo.getFluid(inputStack));
|
||||||
targetFluidInstance.addAmount(1000);
|
targetFluidInstance.addAmount(FluidValue.BUCKET);
|
||||||
|
|
||||||
if(outputStack.isEmpty()){
|
if(outputStack.isEmpty()){
|
||||||
inventory.setInvStack(outputSlot, itemFluidInfo.getEmpty());
|
inventory.setInvStack(outputSlot, itemFluidInfo.getEmpty());
|
||||||
|
@ -101,7 +102,7 @@ public class FluidUtils {
|
||||||
ItemFluidInfo itemFluidInfo = (ItemFluidInfo) inputStack.getItem();
|
ItemFluidInfo itemFluidInfo = (ItemFluidInfo) inputStack.getItem();
|
||||||
FluidInstance sourceFluid = source.getFluidInstance(null);
|
FluidInstance sourceFluid = source.getFluidInstance(null);
|
||||||
|
|
||||||
if(sourceFluid.getFluid() == Fluids.EMPTY || sourceFluid.getAmount() < 1000){
|
if(sourceFluid.getFluid() == Fluids.EMPTY || sourceFluid.getAmount().lessThan(FluidValue.BUCKET)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +124,7 @@ public class FluidUtils {
|
||||||
outputStack.increment(1);
|
outputStack.increment(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceFluid.subtractAmount(1000);
|
sourceFluid.subtractAmount(FluidValue.BUCKET);
|
||||||
|
|
||||||
inputStack.decrement(1);
|
inputStack.decrement(1);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue