move to silk fluids

This commit is contained in:
modmuss50 2019-07-23 21:30:57 +01:00
parent 85554bcfe2
commit 9b46e3237e
18 changed files with 52 additions and 50 deletions

View file

@ -85,6 +85,7 @@ dependencies {
modCompile "net.fabricmc.fabric-api:fabric-api:0.3.0+build.200"
modCompile "io.github.prospector.modmenu:ModMenu:1.5.4-85"
modCompile "io.github.prospector.silk:SilkAPI:1.2.4-43"
// modCompile ('RebornCore:RebornCore-1.14:4.0.0.14') {
// transitive = false

View file

@ -25,7 +25,7 @@
package techreborn.api.fluidreplicator;
import net.minecraft.util.math.BlockPos;
import reborncore.common.fluid.Fluid;
import net.minecraft.fluid.Fluid;
import techreborn.init.TRContent;
import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity;
import techreborn.utils.FluidUtils;

View file

@ -29,8 +29,8 @@ import net.minecraft.item.ItemStack;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.Tank;
import reborncore.common.fluid.Fluid;
import reborncore.common.fluid.FluidStack;
import net.minecraft.fluid.Fluid;
import io.github.prospector.silk.fluid.FluidInstance;
import techreborn.init.ModRecipes;
import techreborn.init.TRContent;
import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity;
@ -75,7 +75,7 @@ public class FluidReplicatorRecipeCrafter extends RecipeCrafter {
}
private boolean canFit(Fluid fluid, Tank tank) {
if (tank.fill(new FluidStack(fluid, 1000), false) != 1000) {
if (tank.fill(new FluidInstance(fluid, 1000), false) != 1000) {
return false;
}
return true;
@ -118,7 +118,7 @@ public class FluidReplicatorRecipeCrafter extends RecipeCrafter {
// Checks to see if it can fit the output
// And fill tank with replicated fluid
if (canFit(currentRecipe.getFluid(), blockEntityFluidReplicator.tank) && currentRecipe.onCraft(blockEntityFluidReplicator)) {
blockEntityFluidReplicator.tank.fill(new FluidStack(currentRecipe.getFluid(), 1000), true);
blockEntityFluidReplicator.tank.fill(new FluidInstance(currentRecipe.getFluid(), 1000), true);
// This uses all the inputs
useAllInputs();
// Reset

View file

@ -25,7 +25,7 @@
package techreborn.api.fluidreplicator;
import org.apache.commons.lang3.Validate;
import reborncore.common.fluid.Fluid;
import net.minecraft.fluid.Fluid;
import techreborn.utils.FluidUtils;
import java.util.ArrayList;

View file

@ -25,7 +25,7 @@
package techreborn.api.generator;
import reborncore.common.fluid.Fluid;
import net.minecraft.fluid.Fluid;
import techreborn.utils.FluidUtils;
public class FluidGeneratorRecipe {

View file

@ -25,7 +25,7 @@
package techreborn.api.generator;
import com.google.common.collect.Sets;
import reborncore.common.fluid.Fluid;
import net.minecraft.fluid.Fluid;
import techreborn.utils.FluidUtils;
import java.util.HashSet;

View file

@ -26,7 +26,7 @@ package techreborn.api.generator;
import reborncore.common.fluid.Fluid;
import net.minecraft.fluid.Fluid;
import java.util.EnumMap;
import java.util.Optional;

View file

@ -28,13 +28,13 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.fluid.FluidStack;
import io.github.prospector.silk.fluid.FluidInstance;
import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity;
public class IndustrialGrinderRecipe extends RebornRecipe {
//TODO 1.14 fluids
FluidStack fluidStack = null;
FluidInstance fluidStack = null;
public IndustrialGrinderRecipe(RebornRecipeType<?> type, Identifier name) {
super(type, name);
@ -46,16 +46,16 @@ public class IndustrialGrinderRecipe extends RebornRecipe {
if (!blockEntity.getMultiBlock()) {
return false;
}
final FluidStack recipeFluid = fluidStack;
final FluidStack tankFluid = blockEntity.tank.getFluid();
final FluidInstance recipeFluid = fluidStack;
final FluidInstance tankFluid = blockEntity.tank.getFluid();
if (fluidStack == null) {
return true;
}
if (tankFluid == null) {
return false;
}
if (tankFluid.isFluidEqual(recipeFluid)) {
if (tankFluid.amount >= recipeFluid.amount) {
if (tankFluid.getFluid().equals(recipeFluid.getFluid())) {
if (tankFluid.getAmount() >= recipeFluid.getAmount()) {
return true;
}
}
@ -65,21 +65,21 @@ public class IndustrialGrinderRecipe extends RebornRecipe {
@Override
public boolean onCraft(final BlockEntity be) {
IndustrialGrinderBlockEntity blockEntity = (IndustrialGrinderBlockEntity) be;
final FluidStack recipeFluid = fluidStack;
final FluidStack tankFluid = blockEntity.tank.getFluid();
final FluidInstance recipeFluid = fluidStack;
final FluidInstance tankFluid = blockEntity.tank.getFluid();
if (fluidStack == null) {
return true;
}
if (tankFluid == null) {
return false;
}
if (tankFluid.isFluidEqual(recipeFluid)) {
if (tankFluid.amount >= recipeFluid.amount) {
if (tankFluid.amount == recipeFluid.amount) {
if (tankFluid.getFluid().equals(recipeFluid.getFluid())) {
if (tankFluid.getAmount() >= recipeFluid.getAmount()) {
if (tankFluid.getAmount() == recipeFluid.getAmount()) {
blockEntity.tank.setFluid(null);
}
else {
tankFluid.amount -= recipeFluid.amount;
tankFluid.subtractAmount(recipeFluid.getAmount());
}
blockEntity.syncWithAll();
return true;

View file

@ -24,17 +24,17 @@
package techreborn.api.recipe.recipes;
import io.github.prospector.silk.fluid.FluidInstance;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.fluid.FluidStack;
import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity;
public class IndustrialSawmillRecipe extends RebornRecipe {
//TODO 1.14 fluids
FluidStack fluidStack = null;
FluidInstance fluidStack = null;
public IndustrialSawmillRecipe(RebornRecipeType<?> type, Identifier name) {
super(type, name);
@ -46,16 +46,16 @@ public class IndustrialSawmillRecipe extends RebornRecipe {
if (!blockEntity.getMutliBlock()) {
return false;
}
final FluidStack recipeFluid = fluidStack;
final FluidStack tankFluid = blockEntity.tank.getFluid();
final FluidInstance recipeFluid = fluidStack;
final FluidInstance tankFluid = blockEntity.tank.getFluid();
if (fluidStack == null) {
return true;
}
if (tankFluid == null) {
return false;
}
if (tankFluid.isFluidEqual(recipeFluid)) {
if (tankFluid.amount >= recipeFluid.amount) {
if (tankFluid.getFluid().equals(recipeFluid.getFluid())) {
if (tankFluid.getAmount() >= recipeFluid.getAmount()) {
return true;
}
}
@ -65,20 +65,20 @@ public class IndustrialSawmillRecipe extends RebornRecipe {
@Override
public boolean onCraft(BlockEntity be) {
IndustrialSawmillBlockEntity blockEntity = (IndustrialSawmillBlockEntity) be;
final FluidStack recipeFluid = fluidStack;
final FluidStack tankFluid = blockEntity.tank.getFluid();
final FluidInstance recipeFluid = fluidStack;
final FluidInstance tankFluid = blockEntity.tank.getFluid();
if (fluidStack == null) {
return true;
}
if (tankFluid == null) {
return false;
}
if (tankFluid.isFluidEqual(recipeFluid)) {
if (tankFluid.amount >= recipeFluid.amount) {
if (tankFluid.amount == recipeFluid.amount) {
if (tankFluid.getFluid().equals(recipeFluid.getFluid())) {
if (tankFluid.getAmount() >= recipeFluid.getAmount()) {
if (tankFluid.getAmount() == recipeFluid.getAmount()) {
blockEntity.tank.setFluid(null);
} else {
tankFluid.amount -= recipeFluid.amount;
tankFluid.subtractAmount(recipeFluid.getAmount());
}
blockEntity.syncWithAll();
return true;

View file

@ -33,7 +33,7 @@ import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.Tank;
import reborncore.common.fluid.FluidStack;
import io.github.prospector.silk.fluid.FluidInstance;
import techreborn.api.generator.EFluidGenerator;
import techreborn.api.generator.FluidGeneratorRecipe;
import techreborn.api.generator.FluidGeneratorRecipeList;
@ -137,7 +137,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
protected boolean acceptFluid() {
if (!inventory.getInvStack(0).isEmpty()) {
FluidStack stack = FluidUtils.getFluidStackInContainer(inventory.getInvStack(0));
FluidInstance stack = FluidUtils.getFluidStackInContainer(inventory.getInvStack(0));
if (stack != null)
return recipes.getRecipeForFluid(stack.getFluid()).isPresent();
}

View file

@ -134,7 +134,7 @@ public class QuantumTankBlockEntity extends MachineBaseBlockEntity
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
if (isReal | hasData) {
if (this.tank.getFluid() != null) {
info.add(new LiteralText(this.tank.getFluidAmount() + " of " + this.tank.getFluidType().getName()));
info.add(new LiteralText(this.tank.getFluidAmount() + " of " + this.tank.getFluidType()));
} else {
info.add(new LiteralText("Empty"));
}

View file

@ -24,9 +24,10 @@
package techreborn.client.gui;
import io.github.prospector.silk.fluid.FluidInstance;
import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.gui.builder.GuiBase;
import reborncore.common.fluid.FluidStack;
import reborncore.common.fluid.FluidUtil;
import techreborn.blockentity.machine.tier3.QuantumTankBlockEntity;
public class GuiQuantumTank extends GuiBase {
@ -52,10 +53,10 @@ public class GuiQuantumTank extends GuiBase {
protected void drawForeground(final int mouseX, final int mouseY) {
super.drawForeground(mouseX, mouseY);
FluidStack fluid = quantumTank.tank.getFluid();
FluidInstance fluid = quantumTank.tank.getFluid();
if(fluid != null){
font.draw( "Fluid Type:", 10, 20, 4210752);
font.draw(fluid.getLocalizedName() + "", 10, 30, 4210752);
font.draw(FluidUtil.getFluidName(fluid) + "", 10, 30, 4210752);
font.draw("Fluid Amount:", 10, 50, 4210752);
font.draw(quantumTank.tank.getFluidAmount() + "mb", 10, 60, 4210752);

View file

@ -26,6 +26,7 @@ package techreborn.init;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Material;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
@ -93,9 +94,8 @@ public enum ModFluids {
Registry.register(Registry.ITEM, identifier, bucket);
}
@Deprecated //TODO this is bad!
public Fluid getFluid() {
return new Fluid();
return stillFluid;
}
public RebornFluidBlock getBlock() {

View file

@ -30,8 +30,8 @@ import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.crafting.RecipeManager;
import reborncore.common.registration.RebornRegister;
import reborncore.common.fluid.Fluid;
import reborncore.common.fluid.FluidStack;
import net.minecraft.fluid.Fluid;
import io.github.prospector.silk.fluid.FluidInstance;
import reborncore.common.fluid.FluidUtil;
import techreborn.TechReborn;
import techreborn.api.recipe.recipes.BlastFurnaceRecipe;
@ -369,7 +369,7 @@ public class ModRecipes {
public static ItemStack getBucketWithFluid(Fluid fluid) {
return FluidUtil.getFilledBucket(new FluidStack(fluid, 1000));
return FluidUtil.getFilledBucket(new FluidInstance(fluid, 1000));
}
}

View file

@ -25,7 +25,7 @@
package techreborn.init.recipes;
import reborncore.common.fluid.Fluid;
import net.minecraft.fluid.Fluid;
import techreborn.api.generator.EFluidGenerator;
import techreborn.api.generator.GeneratorRecipeHelper;
import techreborn.init.ModFluids;

View file

@ -33,7 +33,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.DefaultedList;
import net.minecraft.world.World;
import org.apache.commons.lang3.Validate;
import reborncore.common.fluid.Fluid;
import net.minecraft.fluid.Fluid;
import techreborn.TechReborn;
import techreborn.init.TRContent;
import techreborn.utils.FluidUtils;

View file

@ -26,7 +26,7 @@ package techreborn.items;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.Validate;
import reborncore.common.fluid.Fluid;
import net.minecraft.fluid.Fluid;
import techreborn.utils.FluidUtils;
public class ItemCells {

View file

@ -24,12 +24,12 @@
package techreborn.utils;
import io.github.prospector.silk.fluid.FluidInstance;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.Tank;
import reborncore.common.fluid.Fluid;
import reborncore.common.fluid.FluidStack;
import net.minecraft.fluid.Fluid;
import java.util.Collections;
import java.util.List;
@ -60,7 +60,7 @@ public class FluidUtils {
return false;
}
public static FluidStack getFluidStackInContainer(ItemStack invStack) {
public static FluidInstance getFluidStackInContainer(ItemStack invStack) {
return null;
}
}