Skip to content

Commit

Permalink
More material properties (#12)
Browse files Browse the repository at this point in the history
* Added more FluidAttribute
* Updated FluidPipeProperties
* Added DISTILLED_LIQUID FluidStorageKey
* Added PhysicalProperties implementing IMaterialProperty
* Added tooltips
  • Loading branch information
tekcay authored Nov 27, 2024
1 parent ff83524 commit bcd1ed2
Show file tree
Hide file tree
Showing 20 changed files with 576 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ public PropertyFluidFilter(int maxFluidTemperature,
boolean gasProof,
boolean acidProof,
boolean cryoProof,
boolean plasmaProof) {
boolean plasmaProof,
boolean baseProof,
boolean fluorideProof) {
this.maxFluidTemperature = maxFluidTemperature;
this.gasProof = gasProof;
if (acidProof) setCanContain(FluidAttributes.ACID, true);
if (baseProof) setCanContain(FluidAttributes.BASE, true);
if (fluorideProof) setCanContain(FluidAttributes.FLUORIDE, true);
this.cryoProof = cryoProof;
this.plasmaProof = plasmaProof;
}
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/gregtech/api/fluids/attribute/FluidAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,30 @@ public final class FluidAttributes {
list -> list.add(I18n.format("gregtech.fluid.type_acid.tooltip")),
list -> list.add(I18n.format("gregtech.fluid_pipe.acid_proof")));

/**
* Attribute for basic fluids.
*/
public static final FluidAttribute BASE = new FluidAttribute(gregtechId("base"),
list -> list.add(I18n.format("gregtech.fluid.type_base.tooltip")),
list -> list.add(I18n.format("gregtech.fluid_pipe.base_proof")));
/**
* Attribute for strong fluoride anion containing fluids.
*/
public static final FluidAttribute FLUORIDE = new FluidAttribute(gregtechId("fluoride"),
list -> list.add(I18n.format("gregtech.fluid.type_fluoride.tooltip")),
list -> list.add(I18n.format("gregtech.fluid_pipe.fluoride_proof")));
/**
* Attribute for oxidizing fluids.
*/
public static final FluidAttribute OXIDANT = new FluidAttribute(gregtechId("oxidant"),
list -> list.add(I18n.format("gregtech.fluid.type_oxidant.tooltip")),
list -> list.add(I18n.format("gregtech.fluid_pipe.oxidant_proof")));
/**
* Attribute for reducing fluids.
*/
public static final FluidAttribute REDUCTANT = new FluidAttribute(gregtechId("reductant"),
list -> list.add(I18n.format("gregtech.fluid.type_reductant.tooltip")),
list -> list.add(I18n.format("gregtech.fluid_pipe.reductant_proof")));

private FluidAttributes() {}
}
6 changes: 6 additions & 0 deletions src/main/java/gregtech/api/fluids/store/FluidStorageKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public final class FluidStorageKeys {
m -> m.hasProperty(PropertyKey.DUST) ? "gregtech.fluid.liquid_generic" : "gregtech.fluid.generic",
FluidState.LIQUID);

public static final FluidStorageKey DISTILLED_LIQUID = new FluidStorageKey(gregtechId("distilled_liquid"),
MaterialIconType.distilledLiquid,
m -> "distilled." + m.getName(),
m -> "gregtech.fluid.distilled_liquid",
FluidState.LIQUID, -1);

public static final FluidStorageKey GAS = new FluidStorageKey(gregtechId("gas"),
MaterialIconType.gas,
m -> prefixedRegistryName("gas.", FluidStorageKeys.GAS, m),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ public FilteredFluidStats(int capacity, boolean allowPartialFill, @Nullable IFil
public FilteredFluidStats(int capacity, int maxFluidTemperature, boolean gasProof, boolean acidProof,
boolean cryoProof, boolean plasmaProof, boolean allowPartialFill) {
this(capacity, allowPartialFill,
new PropertyFluidFilter(maxFluidTemperature, gasProof, acidProof, cryoProof, plasmaProof));
new PropertyFluidFilter(maxFluidTemperature, gasProof, acidProof, cryoProof, plasmaProof, false,
false));
}

public FilteredFluidStats(int capacity, int maxFluidTemperature, boolean gasProof, boolean acidProof,
boolean cryoProof, boolean plasmaProof, boolean allowPartialFill, boolean baseProof,
boolean fluorideProof) {
this(capacity, allowPartialFill,
new PropertyFluidFilter(maxFluidTemperature, gasProof, acidProof, cryoProof, plasmaProof, baseProof,
fluorideProof));
}

@Override
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/gregtech/api/unification/material/Material.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ public boolean hasFluid() {
return hasProperty(PropertyKey.FLUID);
}

public PhysicalProperties getPhysicalProperties() {
return this.getProperties().getProperty(PropertyKey.PHYSICAL_PROPERTIES);
}

public void verifyMaterial() {
properties.verify();
flags.verify(this);
Expand Down Expand Up @@ -594,6 +598,24 @@ public Builder gas(@NotNull FluidBuilder builder) {
return fluid(FluidStorageKeys.GAS, builder.state(FluidState.GAS));
}

/**
* Add a distilled fluid for this material.
*
* @see #fluid(FluidStorageKey, FluidState)
*/
public Builder distilledFluid() {
return fluid(FluidStorageKeys.DISTILLED_LIQUID, FluidState.LIQUID);
}

/**
* Add a distilled fluid for this material.
*
* @see #fluid(FluidStorageKey, FluidState)
*/
public Builder distilledFluid(@NotNull FluidBuilder builder) {
return fluid(FluidStorageKeys.DISTILLED_LIQUID, builder.state(FluidState.LIQUID));
}

/**
* Add a {@link DustProperty} to this Material.<br>
* Will be created with a Harvest Level of 2 and no Burn Time (Furnace Fuel).
Expand Down Expand Up @@ -1059,11 +1081,30 @@ public Builder fluidPipeProperties(int maxTemp, int throughput, boolean gasProof
return this;
}

public Builder fluidPipeProperties(int maxTemp, int throughput, boolean gasProof, boolean acidProof,
boolean cryoProof, boolean plasmaProof, boolean baseProof,
boolean fluorideProof) {
properties.setProperty(PropertyKey.FLUID_PIPE,
new FluidPipeProperties(maxTemp, throughput, gasProof, acidProof, cryoProof, plasmaProof, baseProof,
fluorideProof));
return this;
}

public Builder itemPipeProperties(int priority, float stacksPerSec) {
properties.setProperty(PropertyKey.ITEM_PIPE, new ItemPipeProperties(priority, stacksPerSec));
return this;
}

public Builder physicalProperties(PhysicalProperties physicalProperties) {
properties.setProperty(PropertyKey.PHYSICAL_PROPERTIES, physicalProperties);
return this;
}

public Builder physicalProperties(PhysicalProperties.Builder builder) {
properties.setProperty(PropertyKey.PHYSICAL_PROPERTIES, builder.build());
return this;
}

// TODO Clean this up post 2.5 release
@Deprecated
public Builder addDefaultEnchant(Enchantment enchant, int level) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class MaterialIconType {

// BLOCK TEXTURES
public static final MaterialIconType liquid = new MaterialIconType("liquid");
public static final MaterialIconType distilledLiquid = new MaterialIconType("distilled_liquid");
public static final MaterialIconType gas = new MaterialIconType("gas");
public static final MaterialIconType plasma = new MaterialIconType("plasma");
public static final MaterialIconType ore = new MaterialIconType("ore");
Expand Down
Loading

0 comments on commit bcd1ed2

Please sign in to comment.