From 7d8c47fb82904238519e079630dfb8e1ea8c2a55 Mon Sep 17 00:00:00 2001 From: Serenibyss <10861407+serenibyss@users.noreply.github.com> Date: Tue, 12 Dec 2023 10:27:19 -0600 Subject: [PATCH] Fix addFluid expansion method for GrS/CT --- .../material/CTMaterialHelpers.java | 2 +- .../material/MaterialPropertyExpansion.java | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/gregtech/integration/crafttweaker/material/CTMaterialHelpers.java b/src/main/java/gregtech/integration/crafttweaker/material/CTMaterialHelpers.java index 751be8aa3ef..ca5d08a1efa 100644 --- a/src/main/java/gregtech/integration/crafttweaker/material/CTMaterialHelpers.java +++ b/src/main/java/gregtech/integration/crafttweaker/material/CTMaterialHelpers.java @@ -22,7 +22,7 @@ protected static FluidState validateFluidState(String fluidTypeName) { if (fluidTypeName.equals("gas")) return FluidState.GAS; if (fluidTypeName.equals("plasma")) return FluidState.PLASMA; - String message = "Fluid Type must be either \"liquid\", \"gas\", or \"acid\"!"; + String message = "Fluid Type must be either \"liquid\", \"gas\", or \"plasma\"!"; CraftTweakerAPI.logError(message); throw new IllegalArgumentException(message); } diff --git a/src/main/java/gregtech/integration/crafttweaker/material/MaterialPropertyExpansion.java b/src/main/java/gregtech/integration/crafttweaker/material/MaterialPropertyExpansion.java index 0f2c7a3d882..bf4624282cb 100644 --- a/src/main/java/gregtech/integration/crafttweaker/material/MaterialPropertyExpansion.java +++ b/src/main/java/gregtech/integration/crafttweaker/material/MaterialPropertyExpansion.java @@ -156,20 +156,27 @@ public static void addFluid(Material m) { public static void addFluid(Material m, @Optional String fluidTypeName, @Optional boolean hasBlock) { if (checkFrozen("add a Fluid to a material")) return; FluidState type = validateFluidState(fluidTypeName); - if (m.hasProperty(PropertyKey.FLUID)) { - FluidStorage storage = m.getProperty(PropertyKey.FLUID).getStorage(); - FluidBuilder builder = new FluidBuilder(); - if (hasBlock) builder.block(); + FluidProperty property = m.getProperty(PropertyKey.FLUID); + if (property == null) { + property = new FluidProperty(); + m.setProperty(PropertyKey.FLUID, property); + } + + FluidStorage storage = property.getStorage(); + FluidBuilder builder = switch (type) { + case LIQUID -> storage.getQueuedBuilder(FluidStorageKeys.LIQUID); + case GAS -> storage.getQueuedBuilder(FluidStorageKeys.GAS); + case PLASMA -> storage.getQueuedBuilder(FluidStorageKeys.PLASMA); + }; + if (builder == null) { + builder = new FluidBuilder(); switch (type) { case LIQUID -> storage.enqueueRegistration(FluidStorageKeys.LIQUID, builder); case GAS -> storage.enqueueRegistration(FluidStorageKeys.GAS, builder.state(FluidState.GAS)); case PLASMA -> storage.enqueueRegistration(FluidStorageKeys.PLASMA, builder.state(FluidState.PLASMA)); } - } else { - FluidProperty property = new FluidProperty(); - property.getStorage().enqueueRegistration(FluidStorageKeys.LIQUID, new FluidBuilder()); - m.setProperty(PropertyKey.FLUID, property); } + if (hasBlock) builder.block(); } @ZenMethod