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;
|
||||
}
|
||||
|
||||
public int getEnergyPerMb() {
|
||||
return energyPerMb;
|
||||
public int getEnergyPerBucket() {
|
||||
return energyPerMb * 1000;
|
||||
}
|
||||
|
||||
public EFluidGenerator getGeneratorType() {
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.commons.lang3.Validate;
|
|||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import reborncore.common.fluid.container.ItemFluidInfo;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
|
@ -62,7 +63,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
|||
*/
|
||||
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);
|
||||
recipes = GeneratorRecipeHelper.getFluidRecipesForGenerator(type);
|
||||
Validate.notNull(recipes, "null recipe list for " + type.getRecipeID());
|
||||
|
@ -85,7 +86,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
|||
if (ticksSinceLastChange >= 10) {
|
||||
ItemStack inputStack = inventory.getInvStack(0);
|
||||
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());
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
if (tank.getFluidAmount() > 0) {
|
||||
if (!tank.getFluidAmount().isEmpty()) {
|
||||
if (currentRecipe == null || !FluidUtils.fluidEquals(currentRecipe.getFluid(), tank.getFluid()))
|
||||
currentRecipe = getRecipes().getRecipeForFluid(tank.getFluid()).orElse(null);
|
||||
|
||||
if (currentRecipe != null) {
|
||||
final Integer euPerBucket = currentRecipe.getEnergyPerMb() * 1000;
|
||||
final int euPerBucket = currentRecipe.getEnergyPerBucket();
|
||||
final float millibucketsPerTick = euTick * 1000 / (float) euPerBucket;
|
||||
|
||||
if (tryAddingEnergy(euTick)) {
|
||||
pendingWithdraw += millibucketsPerTick;
|
||||
final int currentWithdraw = (int) pendingWithdraw;
|
||||
pendingWithdraw -= currentWithdraw;
|
||||
tank.getFluidInstance().subtractAmount(currentWithdraw);
|
||||
tank.getFluidInstance().subtractAmount(FluidValue.fromRaw(currentWithdraw));
|
||||
lastOutput = world.getTime();
|
||||
}
|
||||
}
|
||||
|
@ -205,11 +206,11 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
|||
this.ticksSinceLastChange = ticksSinceLastChange;
|
||||
}
|
||||
|
||||
public int getTankAmount(){
|
||||
public FluidValue getTankAmount(){
|
||||
return tank.getFluidAmount();
|
||||
}
|
||||
|
||||
public void setTankAmount(int amount){
|
||||
public void setTankAmount(FluidValue amount){
|
||||
tank.setFluidAmount(amount);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
@ -37,7 +38,7 @@ import techreborn.init.TRContent;
|
|||
public class PlasmaGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||
|
||||
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
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
@ -38,7 +39,7 @@ import techreborn.init.TRContent;
|
|||
public class DieselGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||
|
||||
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
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
@ -38,7 +39,7 @@ import techreborn.init.TRContent;
|
|||
public class GasTurbineBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||
|
||||
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
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
@ -38,7 +39,7 @@ import techreborn.init.TRContent;
|
|||
public class SemiFluidGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||
|
||||
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
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.blockentity.generator.BaseFluidGeneratorBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
@ -38,7 +39,7 @@ import techreborn.init.TRContent;
|
|||
public class ThermalGeneratorBlockEntity extends BaseFluidGeneratorBlockEntity implements IContainerProvider {
|
||||
|
||||
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
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.IInventoryAccess;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
|
@ -50,7 +51,7 @@ import javax.annotation.Nullable;
|
|||
public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implements IContainerProvider {
|
||||
|
||||
public MultiblockChecker multiblockChecker;
|
||||
public static final int TANK_CAPACITY = 16_000;
|
||||
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
|
||||
public Tank tank;
|
||||
int ticksSinceLastChange;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.minecraft.util.math.Direction;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import reborncore.common.util.Tank;
|
||||
|
@ -48,7 +49,7 @@ import javax.annotation.Nullable;
|
|||
|
||||
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 MultiblockChecker multiblockChecker;
|
||||
int ticksSinceLastChange;
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.minecraft.util.math.Direction;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import reborncore.common.util.Tank;
|
||||
|
@ -48,7 +49,7 @@ import javax.annotation.Nullable;
|
|||
|
||||
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 MultiblockChecker multiblockChecker;
|
||||
int ticksSinceLastChange;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
package techreborn.blockentity.machine.tier3;
|
||||
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
||||
public class CreativeQuantumTankBlockEntity extends QuantumTankBlockEntity {
|
||||
|
@ -36,7 +37,7 @@ public class CreativeQuantumTankBlockEntity extends QuantumTankBlockEntity {
|
|||
public void tick() {
|
||||
super.tick();
|
||||
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.ContainerBuilder;
|
||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
@ -50,7 +51,7 @@ import java.util.List;
|
|||
public class QuantumTankBlockEntity extends MachineBaseBlockEntity
|
||||
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 QuantumTankBlockEntity(){
|
||||
|
@ -132,7 +133,7 @@ public class QuantumTankBlockEntity extends MachineBaseBlockEntity
|
|||
info.add(new LiteralText("Empty"));
|
||||
}
|
||||
}
|
||||
info.add(new LiteralText("Capacity " + this.tank.getCapacity() + " mb"));
|
||||
info.add(new LiteralText("Capacity " + this.tank.getCapacity()));
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
|
|
|
@ -60,7 +60,7 @@ public class GuiQuantumTank extends GuiBase<BuiltContainer> {
|
|||
font.draw(FluidUtil.getFluidName(fluid) + "", 10, 30, 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.registry.Registry;
|
||||
import reborncore.common.crafting.ingredient.*;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -97,6 +98,6 @@ public class TRRecipeParser {
|
|||
amount = Integer.parseInt(amtStr);
|
||||
}
|
||||
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);
|
||||
JsonObject recipeInfo = new JsonObject();
|
||||
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);
|
||||
} else {
|
||||
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) {
|
||||
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())));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,83 +1,83 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.compat.rei.fluidreplicator;
|
||||
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeDisplay;
|
||||
import me.shedaniel.rei.utils.CollectionUtils;
|
||||
import net.minecraft.util.Identifier;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import techreborn.api.recipe.recipes.FluidReplicatorRecipe;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author drcrazy
|
||||
*/
|
||||
public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
|
||||
|
||||
private final FluidReplicatorRecipe recipe;
|
||||
private List<List<EntryStack>> inputs;
|
||||
private List<EntryStack> output;
|
||||
private FluidInstance fluidInstance;
|
||||
private int energy = 0;
|
||||
|
||||
public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), EntryStack::create));
|
||||
this.fluidInstance = recipe.getFluidInstance();
|
||||
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount()));
|
||||
this.energy = recipe.getPower();
|
||||
}
|
||||
|
||||
public FluidInstance getFluidInstance() {
|
||||
return fluidInstance;
|
||||
}
|
||||
|
||||
public int getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getInputEntries() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntryStack> getOutputEntries() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getRequiredEntries() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getRecipeCategory() {
|
||||
return recipe.getRebornRecipeType().getName();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.compat.rei.fluidreplicator;
|
||||
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeDisplay;
|
||||
import me.shedaniel.rei.utils.CollectionUtils;
|
||||
import net.minecraft.util.Identifier;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import techreborn.api.recipe.recipes.FluidReplicatorRecipe;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author drcrazy
|
||||
*/
|
||||
public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
|
||||
|
||||
private final FluidReplicatorRecipe recipe;
|
||||
private List<List<EntryStack>> inputs;
|
||||
private List<EntryStack> output;
|
||||
private FluidInstance fluidInstance;
|
||||
private int energy = 0;
|
||||
|
||||
public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), EntryStack::create));
|
||||
this.fluidInstance = recipe.getFluidInstance();
|
||||
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue()));
|
||||
this.energy = recipe.getPower();
|
||||
}
|
||||
|
||||
public FluidInstance getFluidInstance() {
|
||||
return fluidInstance;
|
||||
}
|
||||
|
||||
public int getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getInputEntries() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntryStack> getOutputEntries() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getRequiredEntries() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getRecipeCategory() {
|
||||
return recipe.getRebornRecipeType().getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,9 +78,6 @@ public class TechRebornConfig {
|
|||
@Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorMaxEnergy", comment = "Thermal Generator Max Energy (Value in EU)")
|
||||
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)")
|
||||
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)")
|
||||
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)")
|
||||
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)")
|
||||
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)")
|
||||
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)")
|
||||
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)")
|
||||
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)")
|
||||
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)")
|
||||
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)")
|
||||
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")
|
||||
public static int digitalChestMaxStorage = 32768;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import reborncore.common.fluid.container.GenericFluidContainer;
|
||||
import reborncore.common.fluid.container.ItemFluidInfo;
|
||||
|
@ -67,7 +68,7 @@ public class FluidUtils {
|
|||
Fluid currentFluid = targetFluidInstance.getFluid();
|
||||
|
||||
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.getCount() + 1 >= outputStack.getMaxCount()){
|
||||
|
@ -75,10 +76,10 @@ public class FluidUtils {
|
|||
}
|
||||
}
|
||||
|
||||
if(freeSpace >= 1000){
|
||||
if(freeSpace.equalOrMoreThan(FluidValue.BUCKET)){
|
||||
inputStack.decrement(1);
|
||||
targetFluidInstance.setFluid(itemFluidInfo.getFluid(inputStack));
|
||||
targetFluidInstance.addAmount(1000);
|
||||
targetFluidInstance.addAmount(FluidValue.BUCKET);
|
||||
|
||||
if(outputStack.isEmpty()){
|
||||
inventory.setInvStack(outputSlot, itemFluidInfo.getEmpty());
|
||||
|
@ -101,7 +102,7 @@ public class FluidUtils {
|
|||
ItemFluidInfo itemFluidInfo = (ItemFluidInfo) inputStack.getItem();
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -123,7 +124,7 @@ public class FluidUtils {
|
|||
outputStack.increment(1);
|
||||
}
|
||||
|
||||
sourceFluid.subtractAmount(1000);
|
||||
sourceFluid.subtractAmount(FluidValue.BUCKET);
|
||||
|
||||
inputStack.decrement(1);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue