Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix addFluid expansion method for GrS/CT #2287

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down