diff --git a/src/main/java/gregtech/api/capability/IThermalFluidHandlerItemStack.java b/src/main/java/gregtech/api/capability/IThermalFluidHandlerItemStack.java new file mode 100644 index 00000000000..d3e005d592f --- /dev/null +++ b/src/main/java/gregtech/api/capability/IThermalFluidHandlerItemStack.java @@ -0,0 +1,73 @@ +package gregtech.api.capability; + +import gregtech.api.fluids.MaterialFluid; +import gregtech.api.fluids.fluidType.FluidType; +import gregtech.api.fluids.fluidType.FluidTypes; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +/** + * Interface for FluidHandlerItemStacks which handle GT's unique fluid mechanics + * @see FluidType + * @see FluidTypes + * @see MaterialFluid + */ +public interface IThermalFluidHandlerItemStack { + + /** + * + * @param stack the {@link FluidStack} to check + * @return whether the FluidStack can be used to fill this fluid container + */ + default boolean canFillFluidType(FluidStack stack) { + if (stack == null || stack.getFluid() == null) return false; + + Fluid fluid = stack.getFluid(); + if (fluid.getTemperature() > getMaxFluidTemperature()) return false; + // fluids less than 120K are cryogenic + if (fluid.getTemperature() < 120 && !isCryoProof()) return false; + if (fluid.isGaseous() && !isGasProof()) return false; + + if (fluid instanceof MaterialFluid) { + FluidType fluidType = ((MaterialFluid) fluid).getFluidType(); + if (fluidType == FluidTypes.ACID && !isAcidProof()) return false; + if (fluidType == FluidTypes.PLASMA && !isPlasmaProof()) return false; + } + return true; + } + + /** + * This is always checked, regardless of the contained fluid being a {@link MaterialFluid} or not + * + * @return the maximum allowed temperature for a fluid to be stored in this container + */ + int getMaxFluidTemperature(); + + /** + * This is always checked, regardless of the contained fluid being a {@link MaterialFluid} or not + * + * @return true if this fluid container allows gases, otherwise false + */ + boolean isGasProof(); + + /** + * @see FluidTypes + * + * @return true if this fluid container allows acids, otherwise false + */ + boolean isAcidProof(); + + /** + * @see FluidTypes + * + * @return true if this fluid container allows cryogenics, otherwise false + */ + boolean isCryoProof(); + + /** + * @see FluidTypes + * + * @return true if this fluid container allows plasmas, otherwise false + */ + boolean isPlasmaProof(); +} diff --git a/src/main/java/gregtech/api/capability/impl/SimpleThermalFluidHandlerItemStack.java b/src/main/java/gregtech/api/capability/impl/SimpleThermalFluidHandlerItemStack.java index cb5eaeb43d0..76a6585c06a 100644 --- a/src/main/java/gregtech/api/capability/impl/SimpleThermalFluidHandlerItemStack.java +++ b/src/main/java/gregtech/api/capability/impl/SimpleThermalFluidHandlerItemStack.java @@ -1,32 +1,57 @@ package gregtech.api.capability.impl; +import gregtech.api.capability.IThermalFluidHandlerItemStack; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStackSimple; import javax.annotation.Nonnull; -public class SimpleThermalFluidHandlerItemStack extends FluidHandlerItemStackSimple { +public class SimpleThermalFluidHandlerItemStack extends FluidHandlerItemStackSimple implements IThermalFluidHandlerItemStack { - public final int minFluidTemperature; public final int maxFluidTemperature; + private final boolean gasProof; + private final boolean acidProof; + private final boolean cryoProof; + private final boolean plasmaProof; /** * @param container The container itemStack, data is stored on it directly as NBT. * @param capacity The maximum capacity of this fluid tank. */ - public SimpleThermalFluidHandlerItemStack(@Nonnull ItemStack container, int capacity, int minFluidTemperature, int maxFluidTemperature) { + public SimpleThermalFluidHandlerItemStack(@Nonnull ItemStack container, int capacity, int maxFluidTemperature, boolean gasProof, boolean acidProof, boolean cryoProof, boolean plasmaProof) { super(container, capacity); - this.minFluidTemperature = minFluidTemperature; this.maxFluidTemperature = maxFluidTemperature; + this.gasProof = gasProof; + this.acidProof = acidProof; + this.cryoProof = cryoProof; + this.plasmaProof = plasmaProof; } @Override - public boolean canFillFluidType(FluidStack fluid) { - int liquidTemperature = fluid.getFluid().getTemperature(); - return liquidTemperature >= minFluidTemperature && liquidTemperature <= maxFluidTemperature; + public int getMaxFluidTemperature() { + return maxFluidTemperature; } + @Override + public boolean isGasProof() { + return gasProof; + } + + @Override + public boolean isAcidProof() { + return acidProof; + } + + @Override + public boolean isCryoProof() { + return cryoProof; + } + + @Override + public boolean isPlasmaProof() { + return plasmaProof; + } @Override public FluidStack drain(FluidStack resource, boolean doDrain) { diff --git a/src/main/java/gregtech/api/capability/impl/ThermalFluidHandlerItemStack.java b/src/main/java/gregtech/api/capability/impl/ThermalFluidHandlerItemStack.java index 31abb425b1f..b19b489b630 100644 --- a/src/main/java/gregtech/api/capability/impl/ThermalFluidHandlerItemStack.java +++ b/src/main/java/gregtech/api/capability/impl/ThermalFluidHandlerItemStack.java @@ -1,30 +1,31 @@ package gregtech.api.capability.impl; +import gregtech.api.capability.IThermalFluidHandlerItemStack; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack; import javax.annotation.Nonnull; -public class ThermalFluidHandlerItemStack extends FluidHandlerItemStack { +public class ThermalFluidHandlerItemStack extends FluidHandlerItemStack implements IThermalFluidHandlerItemStack { - public final int minFluidTemperature; - public final int maxFluidTemperature; + private final int maxFluidTemperature; + private final boolean gasProof; + private final boolean acidProof; + private final boolean cryoProof; + private final boolean plasmaProof; /** * @param container The container itemStack, data is stored on it directly as NBT. * @param capacity The maximum capacity of this fluid tank. */ - public ThermalFluidHandlerItemStack(@Nonnull ItemStack container, int capacity, int minFluidTemperature, int maxFluidTemperature) { + public ThermalFluidHandlerItemStack(@Nonnull ItemStack container, int capacity, int maxFluidTemperature, boolean gasProof, boolean acidProof, boolean cryoProof, boolean plasmaProof) { super(container, capacity); - this.minFluidTemperature = minFluidTemperature; this.maxFluidTemperature = maxFluidTemperature; - } - - @Override - public boolean canFillFluidType(FluidStack fluid) { - int liquidTemperature = fluid.getFluid().getTemperature(); - return liquidTemperature >= minFluidTemperature && liquidTemperature <= maxFluidTemperature; + this.gasProof = gasProof; + this.acidProof = acidProof; + this.cryoProof = cryoProof; + this.plasmaProof = plasmaProof; } @Override @@ -46,4 +47,29 @@ private void removeTagWhenEmpty(Boolean doDrain) { this.container.setTagCompound(null); } } + + @Override + public int getMaxFluidTemperature() { + return maxFluidTemperature; + } + + @Override + public boolean isGasProof() { + return gasProof; + } + + @Override + public boolean isAcidProof() { + return acidProof; + } + + @Override + public boolean isCryoProof() { + return cryoProof; + } + + @Override + public boolean isPlasmaProof() { + return plasmaProof; + } } diff --git a/src/main/java/gregtech/api/items/metaitem/FilteredFluidStats.java b/src/main/java/gregtech/api/items/metaitem/FilteredFluidStats.java index c60e1b156cc..f032ef5c684 100644 --- a/src/main/java/gregtech/api/items/metaitem/FilteredFluidStats.java +++ b/src/main/java/gregtech/api/items/metaitem/FilteredFluidStats.java @@ -12,31 +12,27 @@ public class FilteredFluidStats implements IItemComponent, IItemCapabilityProvider { - public final int maxCapacity; - public final int minFluidTemperature; - public final int maxFluidTemperature; - public final boolean allowPartlyFill; + public final int capacity; + public final boolean allowPartialFill; private final Function fillPredicate; - public FilteredFluidStats(int maxCapacity, int minFluidTemperature, int maxFluidTemperature, boolean allowPartlyFill, Function fillPredicate) { - this.maxCapacity = maxCapacity; - this.minFluidTemperature = minFluidTemperature; - this.maxFluidTemperature = maxFluidTemperature; - this.allowPartlyFill = allowPartlyFill; + public FilteredFluidStats(int capacity, boolean allowPartialFill, Function fillPredicate) { + this.capacity = capacity; + this.allowPartialFill = allowPartialFill; this.fillPredicate = fillPredicate; } @Override public ICapabilityProvider createProvider(ItemStack itemStack) { - if (allowPartlyFill) { - return new ThermalFluidHandlerItemStack(itemStack, maxCapacity, minFluidTemperature, maxFluidTemperature) { + if (allowPartialFill) { + return new ThermalFluidHandlerItemStack(itemStack, capacity, Integer.MAX_VALUE, true, true, true, true) { @Override public boolean canFillFluidType(FluidStack fluid) { return super.canFillFluidType(fluid) && fillPredicate.apply(fluid); } }; } - return new SimpleThermalFluidHandlerItemStack(itemStack, maxCapacity, minFluidTemperature, maxFluidTemperature) { + return new SimpleThermalFluidHandlerItemStack(itemStack, capacity, Integer.MAX_VALUE, true, true, true, true) { @Override public boolean canFillFluidType(FluidStack fluid) { return super.canFillFluidType(fluid) && fillPredicate.apply(fluid); diff --git a/src/main/java/gregtech/api/items/metaitem/FluidStats.java b/src/main/java/gregtech/api/items/metaitem/FluidStats.java index defd3bbe746..4a50938f171 100644 --- a/src/main/java/gregtech/api/items/metaitem/FluidStats.java +++ b/src/main/java/gregtech/api/items/metaitem/FluidStats.java @@ -9,23 +9,29 @@ public class FluidStats implements IItemComponent, IItemCapabilityProvider { - public final int maxCapacity; - public final int minFluidTemperature; + public final int capacity; public final int maxFluidTemperature; - public final boolean allowPartlyFill; + private final boolean gasProof; + private final boolean acidProof; + private final boolean cryoProof; + private final boolean plasmaProof; + public final boolean allowPartialFill; - public FluidStats(int maxCapacity, int minFluidTemperature, int maxFluidTemperature, boolean allowPartlyFill) { - this.maxCapacity = maxCapacity; - this.minFluidTemperature = minFluidTemperature; + public FluidStats(int capacity, int maxFluidTemperature, boolean gasProof, boolean acidProof, boolean cryoProof, boolean plasmaProof, boolean allowPartialFill) { + this.capacity = capacity; this.maxFluidTemperature = maxFluidTemperature; - this.allowPartlyFill = allowPartlyFill; + this.gasProof = gasProof; + this.acidProof = acidProof; + this.cryoProof = cryoProof; + this.plasmaProof = plasmaProof; + this.allowPartialFill = allowPartialFill; } @Override public ICapabilityProvider createProvider(ItemStack itemStack) { - if (allowPartlyFill) { - return new ThermalFluidHandlerItemStack(itemStack, maxCapacity, minFluidTemperature, maxFluidTemperature); + if (allowPartialFill) { + return new ThermalFluidHandlerItemStack(itemStack, capacity, maxFluidTemperature, gasProof, acidProof, cryoProof, plasmaProof); } - return new SimpleThermalFluidHandlerItemStack(itemStack, maxCapacity, minFluidTemperature, maxFluidTemperature); + return new SimpleThermalFluidHandlerItemStack(itemStack, capacity, maxFluidTemperature, gasProof, acidProof, cryoProof, plasmaProof); } } diff --git a/src/main/java/gregtech/api/items/metaitem/MetaItem.java b/src/main/java/gregtech/api/items/metaitem/MetaItem.java index 943e4769139..b663df6d9b9 100644 --- a/src/main/java/gregtech/api/items/metaitem/MetaItem.java +++ b/src/main/java/gregtech/api/items/metaitem/MetaItem.java @@ -7,6 +7,7 @@ import gregtech.api.GregTechAPI; import gregtech.api.capability.GregtechCapabilities; import gregtech.api.capability.IElectricItem; +import gregtech.api.capability.IThermalFluidHandlerItemStack; import gregtech.api.capability.impl.CombinedCapabilityProvider; import gregtech.api.capability.impl.ElectricItem; import gregtech.api.gui.ModularUI; @@ -57,6 +58,7 @@ import net.minecraftforge.oredict.OreDictionary; import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.builder.ToStringBuilder; +import org.lwjgl.input.Keyboard; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -562,6 +564,19 @@ public void addInformation(@Nonnull ItemStack itemStack, @Nullable World worldIn fluid == null ? 0 : fluid.amount, fluidTankProperties.getCapacity(), fluid == null ? "" : fluid.getLocalizedName())); + + if (fluidHandler instanceof IThermalFluidHandlerItemStack) { + IThermalFluidHandlerItemStack thermalFluidHandler = (IThermalFluidHandlerItemStack) fluidHandler; + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { + lines.add(I18n.format("gregtech.fluid_pipe.max_temperature", thermalFluidHandler.getMaxFluidTemperature())); + if (thermalFluidHandler.isGasProof()) lines.add(I18n.format("gregtech.fluid_pipe.gas_proof")); + if (thermalFluidHandler.isAcidProof()) lines.add(I18n.format("gregtech.fluid_pipe.acid_proof")); + if (thermalFluidHandler.isCryoProof()) lines.add(I18n.format("gregtech.fluid_pipe.cryo_proof")); + if (thermalFluidHandler.isPlasmaProof()) lines.add(I18n.format("gregtech.fluid_pipe.plasma_proof")); + } else if (thermalFluidHandler.isGasProof() || thermalFluidHandler.isAcidProof() || thermalFluidHandler.isCryoProof() || thermalFluidHandler.isPlasmaProof()) { + lines.add(I18n.format("gregtech.tooltip.fluid_pipe_hold_shift")); + } + } } for (IItemBehaviour behaviour : getBehaviours(itemStack)) { diff --git a/src/main/java/gregtech/api/unification/material/materials/SecondDegreeMaterials.java b/src/main/java/gregtech/api/unification/material/materials/SecondDegreeMaterials.java index 00a895a8af1..041b69d7912 100644 --- a/src/main/java/gregtech/api/unification/material/materials/SecondDegreeMaterials.java +++ b/src/main/java/gregtech/api/unification/material/materials/SecondDegreeMaterials.java @@ -20,7 +20,7 @@ public static void register() { .color(0xFAFAFA).iconSet(GLASS) .flags(GENERATE_LENS, NO_SMASHING, EXCLUDE_BLOCK_CRAFTING_RECIPES, DECOMPOSITION_BY_CENTRIFUGING) .components(SiliconDioxide, 1) - .fluidTemp(1400) + .fluidTemp(1200) .build(); Perlite = new Material.Builder(2001, "perlite") diff --git a/src/main/java/gregtech/common/items/MetaItem1.java b/src/main/java/gregtech/common/items/MetaItem1.java index 9be081f2d84..94e90d7dafc 100644 --- a/src/main/java/gregtech/common/items/MetaItem1.java +++ b/src/main/java/gregtech/common/items/MetaItem1.java @@ -12,6 +12,7 @@ import gregtech.api.unification.material.MarkerMaterials.Component; import gregtech.api.unification.material.MarkerMaterials.Tier; import gregtech.api.unification.material.Materials; +import gregtech.api.unification.material.properties.PropertyKey; import gregtech.api.unification.ore.OrePrefix; import gregtech.api.unification.stack.ItemMaterialInfo; import gregtech.api.unification.stack.MaterialStack; @@ -119,31 +120,35 @@ public void registerSubItems() { } // Fluid Cells: ID 78-88 - FLUID_CELL = addItem(78, "fluid_cell").addComponents(new FluidStats(1000, Integer.MIN_VALUE, Integer.MAX_VALUE, false)); + FLUID_CELL = addItem(78, "fluid_cell").addComponents(new FluidStats(1000, 1800, true, false, false, false, false)); - FLUID_CELL_UNIVERSAL = addItem(79, "fluid_cell.universal").addComponents(new FluidStats(1000, Integer.MIN_VALUE, Integer.MAX_VALUE, true)); + FLUID_CELL_UNIVERSAL = addItem(79, "fluid_cell.universal").addComponents(new FluidStats(1000, 1800, true, false, false, false, false)); FLUID_CELL_LARGE_STEEL = addItem(80, "large_fluid_cell.steel") - .addComponents(new FluidStats(8000, Integer.MIN_VALUE, Integer.MAX_VALUE, true)) + .addComponents(new FluidStats(8000, Materials.Steel.getProperty(PropertyKey.FLUID_PIPE).getMaxFluidTemperature(), true, false, false, false, true)) .setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Steel, M * 4))); // ingot * 4 FLUID_CELL_LARGE_ALUMINIUM = addItem(81, "large_fluid_cell.aluminium") - .addComponents(new FluidStats(32000, Integer.MIN_VALUE, Integer.MAX_VALUE, true)) + .addComponents(new FluidStats(32000, Materials.Aluminium.getProperty(PropertyKey.FLUID_PIPE).getMaxFluidTemperature(), true, false, false, false, true)) .setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Aluminium, M * 4))); // ingot * 4 FLUID_CELL_LARGE_STAINLESS_STEEL = addItem(82, "large_fluid_cell.stainless_steel") - .addComponents(new FluidStats(64000, Integer.MIN_VALUE, Integer.MAX_VALUE, true)) + .addComponents(new FluidStats(64000, Materials.StainlessSteel.getProperty(PropertyKey.FLUID_PIPE).getMaxFluidTemperature(), true, true, true, false, true)) .setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.StainlessSteel, M * 6))); // ingot * 6 FLUID_CELL_LARGE_TITANIUM = addItem(83, "large_fluid_cell.titanium") - .addComponents(new FluidStats(128000, Integer.MIN_VALUE, Integer.MAX_VALUE, true)) + .addComponents(new FluidStats(128000, Materials.Titanium.getProperty(PropertyKey.FLUID_PIPE).getMaxFluidTemperature(), true, false, false, false, true)) .setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Titanium, M * 6))); // ingot * 6 FLUID_CELL_LARGE_TUNGSTEN_STEEL = addItem(84, "large_fluid_cell.tungstensteel") - .addComponents(new FluidStats(512000, Integer.MIN_VALUE, Integer.MAX_VALUE, true)) + .addComponents(new FluidStats(512000, Materials.TungstenSteel.getProperty(PropertyKey.FLUID_PIPE).getMaxFluidTemperature(), true, false, false, false, true)) .setMaxStackSize(32) .setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.TungstenSteel, M * 8))); // ingot * 8 + FLUID_CELL_GLASS_VIAL = addItem(85, "fluid_cell.glass_vial") + .addComponents(new FluidStats(1000, 1200, false, true, false, false, true)) + .setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Glass, M / 4))); // small dust + // Limited-Use Items: ID 89-95 TOOL_MATCHES = addItem(89, "tool.matches") @@ -153,13 +158,13 @@ public void registerSubItems() { TOOL_LIGHTER_INVAR = addItem(91, "tool.lighter.invar") .setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Invar, M * 2))) .addComponents(new LighterBehaviour(new ResourceLocation(GTValues.MODID, "lighter_open"), true, true, true)) - .addComponents(new FilteredFluidStats(100, 0, Integer.MAX_VALUE, true, + .addComponents(new FilteredFluidStats(100, true, fs -> fs.getFluid().equals(Materials.Butane.getFluid()) || fs.getFluid().equals(Materials.Propane.getFluid()))) .setMaxStackSize(1); TOOL_LIGHTER_PLATINUM = addItem(92, "tool.lighter.platinum") .setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Platinum, M * 2))) .addComponents(new LighterBehaviour(new ResourceLocation(GTValues.MODID, "lighter_open"), true, true, true)) - .addComponents(new FilteredFluidStats(1000, 0, Integer.MAX_VALUE, true, + .addComponents(new FilteredFluidStats(1000, true, fs -> fs.getFluid().equals(Materials.Butane.getFluid()) || fs.getFluid().equals(Materials.Propane.getFluid()))) .setMaxStackSize(1) .setRarity(EnumRarity.UNCOMMON); diff --git a/src/main/java/gregtech/common/items/MetaItems.java b/src/main/java/gregtech/common/items/MetaItems.java index a8c8acdffd4..64b922e26e8 100644 --- a/src/main/java/gregtech/common/items/MetaItems.java +++ b/src/main/java/gregtech/common/items/MetaItems.java @@ -110,6 +110,7 @@ private MetaItems() { public static MetaItem.MetaValueItem FLUID_CELL_LARGE_STAINLESS_STEEL; public static MetaItem.MetaValueItem FLUID_CELL_LARGE_TITANIUM; public static MetaItem.MetaValueItem FLUID_CELL_LARGE_TUNGSTEN_STEEL; + public static MetaItem.MetaValueItem FLUID_CELL_GLASS_VIAL; public static MetaItem.MetaValueItem TOOL_MATCHES; public static MetaItem.MetaValueItem TOOL_MATCHBOX; diff --git a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityDrum.java b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityDrum.java index 4794ee831bb..8f0bdf2a72b 100644 --- a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityDrum.java +++ b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityDrum.java @@ -8,12 +8,18 @@ import codechicken.lib.vec.Matrix4; import gregtech.api.capability.impl.FilteredFluidHandler; import gregtech.api.capability.impl.ThermalFluidHandlerItemStack; +import gregtech.api.fluids.MaterialFluid; +import gregtech.api.fluids.fluidType.FluidType; +import gregtech.api.fluids.fluidType.FluidTypes; import gregtech.api.gui.ModularUI; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; -import gregtech.client.renderer.texture.Textures; +import gregtech.api.recipes.ModHandler; import gregtech.api.unification.material.Material; +import gregtech.api.unification.material.properties.FluidPipeProperties; +import gregtech.api.unification.material.properties.PropertyKey; import gregtech.api.util.GTUtility; +import gregtech.client.renderer.texture.Textures; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; @@ -28,6 +34,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.Constants; +import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidUtil; @@ -36,12 +43,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.Pair; +import org.lwjgl.input.Keyboard; import javax.annotation.Nullable; import java.io.IOException; import java.util.List; -import static gregtech.api.capability.GregtechDataCodes.*; +import static gregtech.api.capability.GregtechDataCodes.UPDATE_AUTO_OUTPUT; import static gregtech.api.recipes.ModHandler.isMaterialWood; import static gregtech.api.unification.material.info.MaterialFlags.FLAMMABLE; @@ -56,6 +64,9 @@ public MetaTileEntityDrum(ResourceLocation metaTileEntityId, Material material, super(metaTileEntityId); this.tankSize = tankSize; this.material = material; + if (!isMaterialWood(material) && !this.material.hasProperty(PropertyKey.FLUID_PIPE)) { + throw new IllegalArgumentException(String.format("Material %s requires FluidPipePropety for Drums", material)); + } initializeInventory(); } @@ -85,7 +96,7 @@ public boolean isOpaqueCube() { @Override public String getHarvestTool() { - return isMaterialWood(material) ? "axe" : "pickaxe"; + return isMaterialWood(material) ? "axe" : "wrench"; } @Override @@ -96,7 +107,33 @@ public boolean hasFrontFacing() { @Override protected void initializeInventory() { super.initializeInventory(); - this.fluidTank = new FilteredFluidHandler(tankSize).setFillPredicate(isMaterialWood(material) ? (fs -> !fs.getFluid().isGaseous() && fs.getFluid().getTemperature() > 325) : fs -> true); + this.fluidTank = new FilteredFluidHandler(tankSize) + .setFillPredicate(stack -> { + if (stack == null || stack.getFluid() == null) return false; + + Fluid fluid = stack.getFluid(); + if (isMaterialWood(material)) { + boolean meetsGTRequirements = true; + if (fluid instanceof MaterialFluid) { + FluidType fluidType = ((MaterialFluid) fluid).getFluidType(); + meetsGTRequirements = fluidType != FluidTypes.ACID && fluidType != FluidTypes.PLASMA; + } + return fluid.getTemperature() <= 340 && !fluid.isGaseous() && meetsGTRequirements; + } + + FluidPipeProperties pipeProperties = material.getProperty(PropertyKey.FLUID_PIPE); + if (fluid.getTemperature() > pipeProperties.getMaxFluidTemperature()) return false; + // fluids less than 120K are cryogenic + if (fluid.getTemperature() < 120 && !pipeProperties.isCryoProof()) return false; + if (fluid.isGaseous() && !pipeProperties.isGasProof()) return false; + + if (fluid instanceof MaterialFluid) { + FluidType fluidType = ((MaterialFluid) fluid).getFluidType(); + if (fluidType == FluidTypes.ACID && !pipeProperties.isAcidProof()) return false; + if (fluidType == FluidTypes.PLASMA && !pipeProperties.isPlasmaProof()) return false; + } + return true; + }); this.fluidInventory = fluidTank; } @@ -122,8 +159,17 @@ public void writeItemStackData(NBTTagCompound itemStack) { @Override public ICapabilityProvider initItemStackCapabilities(ItemStack itemStack) { - int maxTemperature = (material.hasFlag(FLAMMABLE) || isMaterialWood(material)) ? 325 : Integer.MAX_VALUE; - return new ThermalFluidHandlerItemStack(itemStack, tankSize, Integer.MIN_VALUE, maxTemperature); + if (isMaterialWood(material) || material.hasFlag(FLAMMABLE)) { + return new ThermalFluidHandlerItemStack(itemStack, tankSize, 340, false, false, false, false); + } + + FluidPipeProperties pipeProperties = material.getProperty(PropertyKey.FLUID_PIPE); + return new ThermalFluidHandlerItemStack(itemStack, tankSize, + pipeProperties.getMaxFluidTemperature(), + pipeProperties.isGasProof(), + pipeProperties.isAcidProof(), + pipeProperties.isCryoProof(), + pipeProperties.isPlasmaProof()); } @Override @@ -241,6 +287,22 @@ public int getDefaultPaintingColor() { public void addInformation(ItemStack stack, @Nullable World player, List tooltip, boolean advanced) { tooltip.add(I18n.format("gregtech.universal.tooltip.fluid_storage_capacity", tankSize)); + if (ModHandler.isMaterialWood(material)) { + tooltip.add(I18n.format("gregtech.fluid_pipe.max_temperature", 340)); + tooltip.add(I18n.format("gregtech.fluid_pipe.not_gas_proof")); + } else { + FluidPipeProperties pipeProperties = material.getProperty(PropertyKey.FLUID_PIPE); + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { + tooltip.add(I18n.format("gregtech.fluid_pipe.max_temperature", pipeProperties.getMaxFluidTemperature())); + if (pipeProperties.isGasProof()) tooltip.add(I18n.format("gregtech.fluid_pipe.gas_proof")); + if (pipeProperties.isAcidProof()) tooltip.add(I18n.format("gregtech.fluid_pipe.acid_proof")); + if (pipeProperties.isCryoProof()) tooltip.add(I18n.format("gregtech.fluid_pipe.cryo_proof")); + if (pipeProperties.isPlasmaProof()) tooltip.add(I18n.format("gregtech.fluid_pipe.plasma_proof")); + } else { + tooltip.add(I18n.format("gregtech.tooltip.fluid_pipe_hold_shift")); + } + } + NBTTagCompound tagCompound = stack.getTagCompound(); if (tagCompound != null && tagCompound.hasKey("Fluid", Constants.NBT.TAG_COMPOUND)) { FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(tagCompound.getCompoundTag("Fluid")); diff --git a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumTank.java b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumTank.java index b7fa46da5d8..124ba6a6250 100644 --- a/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumTank.java +++ b/src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityQuantumTank.java @@ -380,7 +380,7 @@ public T getCapability(Capability capability, EnumFacing side) { @Override public ICapabilityProvider initItemStackCapabilities(ItemStack itemStack) { - return new ThermalFluidHandlerItemStack(itemStack, maxFluidCapacity, Integer.MIN_VALUE, Integer.MAX_VALUE); + return new ThermalFluidHandlerItemStack(itemStack, maxFluidCapacity, Integer.MAX_VALUE, true, true, true, true); } @Override diff --git a/src/main/java/gregtech/common/pipelike/itempipe/BlockItemPipe.java b/src/main/java/gregtech/common/pipelike/itempipe/BlockItemPipe.java index f191c2316ca..95f229576d2 100644 --- a/src/main/java/gregtech/common/pipelike/itempipe/BlockItemPipe.java +++ b/src/main/java/gregtech/common/pipelike/itempipe/BlockItemPipe.java @@ -39,7 +39,7 @@ public class BlockItemPipe extends BlockMaterialPipe