Skip to content

Commit

Permalink
catch exceptions from Fluid#fluidType and log an error instead of cra…
Browse files Browse the repository at this point in the history
…shing

#1251
  • Loading branch information
desht committed Nov 9, 2023
1 parent 1cef955 commit cd81a92
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/java/me/desht/pneumaticcraft/common/fluid/FluidSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import me.desht.pneumaticcraft.common.config.ConfigHelper;
import me.desht.pneumaticcraft.common.core.ModFluids;
import me.desht.pneumaticcraft.common.core.ModItems;
import me.desht.pneumaticcraft.lib.Log;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.registries.ForgeRegistries;
Expand All @@ -36,10 +38,18 @@ public static void init() {

// register hot fluids as (very inefficient) fuels
for (Fluid fluid : ForgeRegistries.FLUIDS.getValues()) {
int temperature = fluid.getFluidType().getTemperature();
if (temperature >= ConfigHelper.common().general.minFluidFuelTemperature.get() && fluid.isSource(fluid.defaultFluidState())) {
// non-API usage... register an explicit fluid rather than a tag
FuelRegistry.getInstance().registerHotFluid(fluid, (temperature - 300) * 40, 0.25f);
try {
int temperature = fluid.getFluidType().getTemperature();
if (temperature >= ConfigHelper.common().general.minFluidFuelTemperature.get() && fluid.isSource(fluid.defaultFluidState())) {
// non-API usage... register an explicit fluid rather than a tag
FuelRegistry.getInstance().registerHotFluid(fluid, (temperature - 300) * 40, 0.25f);
}
} catch (RuntimeException e) {
ResourceLocation fluidId = ForgeRegistries.FLUIDS.getKey(fluid);
Log.error("Caught exception while checking the fluid type of {}: {}", fluidId, e.getMessage());
if (fluidId != null) {
Log.error("Looks like {} isn't setting a fluid type for this fluid, please report to the mod author", fluidId.getNamespace());
}
}
}

Expand Down

0 comments on commit cd81a92

Please sign in to comment.