Skip to content

Commit

Permalink
Reimplement alternative fluid names (#2238)
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Dec 2, 2023
1 parent a7e1a2c commit 86517ee
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
16 changes: 16 additions & 0 deletions src/main/java/gregtech/api/fluids/FluidBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class FluidBuilder {

private boolean hasFluidBlock = false;
private boolean hasBucket = true;
private String alternativeName = null;

public FluidBuilder() {}

Expand Down Expand Up @@ -213,6 +214,15 @@ private static int convertViscosity(double viscosity) {
return this;
}

/**
* @param name Alternative registry name for this fluid to look for
* @return this
*/
public @NotNull FluidBuilder alternativeName(@NotNull String name) {
this.alternativeName = name;
return this;
}

/**
* Mark this fluid as having a custom still texture
*
Expand Down Expand Up @@ -275,7 +285,13 @@ private static int convertViscosity(double viscosity) {
throw new IllegalStateException("Could not determine fluid name");
}

// try to find an already registered fluid that we can use instead of a new one
Fluid fluid = FluidRegistry.getFluid(name);
if (fluid == null && alternativeName != null) {
// try to use alternative fluid name if needed
fluid = FluidRegistry.getFluid(alternativeName);
}

boolean needsRegistration = false;
if (fluid == null) {
needsRegistration = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ public static void register() {
.dust(0)
.liquid(new FluidBuilder()
.temperature(273)
.customStill())
.customStill()
.alternativeName("fluid.ice"))
.color(0xC8C8FF).iconSet(SHINY)
.flags(NO_SMASHING, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES, DISABLE_DECOMPOSITION)
.components(Hydrogen, 2, Oxygen, 1)
Expand Down Expand Up @@ -1281,7 +1282,7 @@ public static void register() {
.build();

DistilledWater = new Material.Builder(421, gregtechId("distilled_water"))
.fluid()
.liquid(new FluidBuilder().alternativeName("fluidDistWater"))
.color(0x4A94FF)
.flags(DISABLE_DECOMPOSITION)
.components(Hydrogen, 2, Oxygen, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public static void register() {
// FREE ID 1053

Ethanol = new Material.Builder(1054, gregtechId("ethanol"))
.liquid(new FluidBuilder().customStill())
.liquid(new FluidBuilder().customStill().alternativeName("bio.ethanol"))
.color(0xFC4C04)
.flags(DISABLE_DECOMPOSITION)
.components(Carbon, 2, Hydrogen, 6, Oxygen, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void register() {
.flags(STICKY).build();

Diesel = new Material.Builder(1508, gregtechId("diesel"))
.liquid(new FluidBuilder().customStill())
.liquid(new FluidBuilder().customStill().alternativeName("fuel"))
.color(0xFCF404)
.flags(FLAMMABLE, EXPLOSIVE).build();

Expand All @@ -72,7 +72,7 @@ public static void register() {
.color(0x0E2950).build();

SeedOil = new Material.Builder(1514, gregtechId("seed_oil"))
.liquid(new FluidBuilder().customStill())
.liquid(new FluidBuilder().customStill().alternativeName("seed.oil"))
.color(0xE4FC8C)
.flags(STICKY, FLAMMABLE).build();

Expand Down

0 comments on commit 86517ee

Please sign in to comment.