From 5e5e997b93870fd34c69584fefc14a9002ba412e Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Thu, 12 Dec 2019 12:42:33 +0000 Subject: [PATCH] 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. --- .../api/generator/FluidGeneratorRecipe.java | 4 +- .../BaseFluidGeneratorBlockEntity.java | 15 +- .../generator/PlasmaGeneratorBlockEntity.java | 3 +- .../advanced/DieselGeneratorBlockEntity.java | 3 +- .../advanced/GasTurbineBlockEntity.java | 3 +- .../SemiFluidGeneratorBlockEntity.java | 3 +- .../advanced/ThermalGeneratorBlockEntity.java | 3 +- .../FluidReplicatorBlockEntity.java | 3 +- .../IndustrialGrinderBlockEntity.java | 3 +- .../IndustrialSawmillBlockEntity.java | 3 +- .../tier3/CreativeQuantumTankBlockEntity.java | 3 +- .../machine/tier3/QuantumTankBlockEntity.java | 5 +- .../techreborn/client/gui/GuiQuantumTank.java | 2 +- .../compat/libcd/TRRecipeParser.java | 3 +- .../techreborn/compat/libcd/TRTweaker.java | 2 +- .../compat/rei/MachineRecipeDisplay.java | 2 +- .../FluidReplicatorRecipeDisplay.java | 166 +++++++++--------- .../techreborn/config/TechRebornConfig.java | 18 -- .../java/techreborn/utils/FluidUtils.java | 11 +- 19 files changed, 125 insertions(+), 130 deletions(-) diff --git a/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java b/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java index fa0e64a21..1fab0324f 100644 --- a/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java +++ b/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java @@ -43,8 +43,8 @@ public class FluidGeneratorRecipe { return fluid; } - public int getEnergyPerMb() { - return energyPerMb; + public int getEnergyPerBucket() { + return energyPerMb * 1000; } public EFluidGenerator getGeneratorType() { diff --git a/src/main/java/techreborn/blockentity/generator/BaseFluidGeneratorBlockEntity.java b/src/main/java/techreborn/blockentity/generator/BaseFluidGeneratorBlockEntity.java index 8acf290a7..003b794fd 100644 --- a/src/main/java/techreborn/blockentity/generator/BaseFluidGeneratorBlockEntity.java +++ b/src/main/java/techreborn/blockentity/generator/BaseFluidGeneratorBlockEntity.java @@ -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); } diff --git a/src/main/java/techreborn/blockentity/generator/PlasmaGeneratorBlockEntity.java b/src/main/java/techreborn/blockentity/generator/PlasmaGeneratorBlockEntity.java index aebb16b10..7904078bb 100644 --- a/src/main/java/techreborn/blockentity/generator/PlasmaGeneratorBlockEntity.java +++ b/src/main/java/techreborn/blockentity/generator/PlasmaGeneratorBlockEntity.java @@ -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 diff --git a/src/main/java/techreborn/blockentity/generator/advanced/DieselGeneratorBlockEntity.java b/src/main/java/techreborn/blockentity/generator/advanced/DieselGeneratorBlockEntity.java index 638d30a52..172a71a20 100644 --- a/src/main/java/techreborn/blockentity/generator/advanced/DieselGeneratorBlockEntity.java +++ b/src/main/java/techreborn/blockentity/generator/advanced/DieselGeneratorBlockEntity.java @@ -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 diff --git a/src/main/java/techreborn/blockentity/generator/advanced/GasTurbineBlockEntity.java b/src/main/java/techreborn/blockentity/generator/advanced/GasTurbineBlockEntity.java index 6cb538810..510950e39 100644 --- a/src/main/java/techreborn/blockentity/generator/advanced/GasTurbineBlockEntity.java +++ b/src/main/java/techreborn/blockentity/generator/advanced/GasTurbineBlockEntity.java @@ -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 diff --git a/src/main/java/techreborn/blockentity/generator/advanced/SemiFluidGeneratorBlockEntity.java b/src/main/java/techreborn/blockentity/generator/advanced/SemiFluidGeneratorBlockEntity.java index 7b44fa2b2..3279c0422 100644 --- a/src/main/java/techreborn/blockentity/generator/advanced/SemiFluidGeneratorBlockEntity.java +++ b/src/main/java/techreborn/blockentity/generator/advanced/SemiFluidGeneratorBlockEntity.java @@ -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 diff --git a/src/main/java/techreborn/blockentity/generator/advanced/ThermalGeneratorBlockEntity.java b/src/main/java/techreborn/blockentity/generator/advanced/ThermalGeneratorBlockEntity.java index 012809452..02e7e739f 100644 --- a/src/main/java/techreborn/blockentity/generator/advanced/ThermalGeneratorBlockEntity.java +++ b/src/main/java/techreborn/blockentity/generator/advanced/ThermalGeneratorBlockEntity.java @@ -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 diff --git a/src/main/java/techreborn/blockentity/machine/multiblock/FluidReplicatorBlockEntity.java b/src/main/java/techreborn/blockentity/machine/multiblock/FluidReplicatorBlockEntity.java index 799cdd562..87e904701 100644 --- a/src/main/java/techreborn/blockentity/machine/multiblock/FluidReplicatorBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/multiblock/FluidReplicatorBlockEntity.java @@ -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; diff --git a/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialGrinderBlockEntity.java b/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialGrinderBlockEntity.java index 010be205e..f4181d2c7 100644 --- a/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialGrinderBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialGrinderBlockEntity.java @@ -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; diff --git a/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialSawmillBlockEntity.java b/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialSawmillBlockEntity.java index d09abba12..077d6b239 100644 --- a/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialSawmillBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/multiblock/IndustrialSawmillBlockEntity.java @@ -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; diff --git a/src/main/java/techreborn/blockentity/machine/tier3/CreativeQuantumTankBlockEntity.java b/src/main/java/techreborn/blockentity/machine/tier3/CreativeQuantumTankBlockEntity.java index 891d08716..5c939bdcd 100644 --- a/src/main/java/techreborn/blockentity/machine/tier3/CreativeQuantumTankBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/tier3/CreativeQuantumTankBlockEntity.java @@ -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); } } diff --git a/src/main/java/techreborn/blockentity/machine/tier3/QuantumTankBlockEntity.java b/src/main/java/techreborn/blockentity/machine/tier3/QuantumTankBlockEntity.java index a2f92d847..d3b7a5609 100644 --- a/src/main/java/techreborn/blockentity/machine/tier3/QuantumTankBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/tier3/QuantumTankBlockEntity.java @@ -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 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 diff --git a/src/main/java/techreborn/client/gui/GuiQuantumTank.java b/src/main/java/techreborn/client/gui/GuiQuantumTank.java index 173d8090f..5f4b50b85 100644 --- a/src/main/java/techreborn/client/gui/GuiQuantumTank.java +++ b/src/main/java/techreborn/client/gui/GuiQuantumTank.java @@ -60,7 +60,7 @@ public class GuiQuantumTank extends GuiBase { 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); } } diff --git a/src/main/java/techreborn/compat/libcd/TRRecipeParser.java b/src/main/java/techreborn/compat/libcd/TRRecipeParser.java index 1279f759f..f92530b4a 100644 --- a/src/main/java/techreborn/compat/libcd/TRRecipeParser.java +++ b/src/main/java/techreborn/compat/libcd/TRRecipeParser.java @@ -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)); } } diff --git a/src/main/java/techreborn/compat/libcd/TRTweaker.java b/src/main/java/techreborn/compat/libcd/TRTweaker.java index 45d9d1bf8..c33177a73 100644 --- a/src/main/java/techreborn/compat/libcd/TRTweaker.java +++ b/src/main/java/techreborn/compat/libcd/TRTweaker.java @@ -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() diff --git a/src/main/java/techreborn/compat/rei/MachineRecipeDisplay.java b/src/main/java/techreborn/compat/rei/MachineRecipeDisplay.java index cdbe54fa8..8d34f3b48 100644 --- a/src/main/java/techreborn/compat/rei/MachineRecipeDisplay.java +++ b/src/main/java/techreborn/compat/rei/MachineRecipeDisplay.java @@ -56,7 +56,7 @@ public class MachineRecipeDisplay 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()))); } } diff --git a/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeDisplay.java b/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeDisplay.java index 5f97064ae..5ea728dc3 100644 --- a/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeDisplay.java +++ b/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeDisplay.java @@ -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> inputs; - private List 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> getInputEntries() { - return inputs; - } - - @Override - public List getOutputEntries() { - return output; - } - - @Override - public List> 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> inputs; + private List 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> getInputEntries() { + return inputs; + } + + @Override + public List getOutputEntries() { + return output; + } + + @Override + public List> getRequiredEntries() { + return inputs; + } + + @Override + public Identifier getRecipeCategory() { + return recipe.getRebornRecipeType().getName(); + } +} diff --git a/src/main/java/techreborn/config/TechRebornConfig.java b/src/main/java/techreborn/config/TechRebornConfig.java index 3e4284f4c..0fa38c98f 100644 --- a/src/main/java/techreborn/config/TechRebornConfig.java +++ b/src/main/java/techreborn/config/TechRebornConfig.java @@ -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; diff --git a/src/main/java/techreborn/utils/FluidUtils.java b/src/main/java/techreborn/utils/FluidUtils.java index 04a900da9..5adc4b88e 100644 --- a/src/main/java/techreborn/utils/FluidUtils.java +++ b/src/main/java/techreborn/utils/FluidUtils.java @@ -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);