From 37d63b3fe95718aafe8f9fcd8fd2f6952c3525c3 Mon Sep 17 00:00:00 2001 From: King Lemming Date: Fri, 10 Apr 2015 20:09:58 -0400 Subject: [PATCH] Adds a warning to the FluidContainerRegistry when a mod does something stupid! Also denies the registration. Signed-off-by: King Lemming --- .../fluids/FluidContainerRegistry.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java b/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java index 9702c28bf..7d6a963e1 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java +++ b/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java @@ -7,10 +7,9 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; - import com.google.common.collect.Maps; import com.google.common.collect.Sets; - +import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -113,7 +112,7 @@ public abstract class FluidContainerRegistry * ItemStack representing the container when it is full. * @param emptyContainer * ItemStack representing the container when it is empty. - * @return True if container was successfully registered; false if it already is. + * @return True if container was successfully registered; false if it already is, or an invalid parameter was passed. */ public static boolean registerFluidContainer(Fluid fluid, ItemStack filledContainer, ItemStack emptyContainer) { @@ -131,7 +130,7 @@ public abstract class FluidContainerRegistry * FluidStack containing the type and amount of the fluid stored in the item. * @param filledContainer * ItemStack representing the container when it is full. - * @return True if container was successfully registered; false if it already is. + * @return True if container was successfully registered; false if it already is, or an invalid parameter was passed. */ public static boolean registerFluidContainer(FluidStack stack, ItemStack filledContainer) { @@ -146,7 +145,7 @@ public abstract class FluidContainerRegistry * Fluid type that is stored in the item. * @param filledContainer * ItemStack representing the container when it is full. - * @return True if container was successfully registered; false if it already is. + * @return True if container was successfully registered; false if it already is, or an invalid parameter was passed. */ public static boolean registerFluidContainer(Fluid fluid, ItemStack filledContainer) { @@ -162,14 +161,19 @@ public abstract class FluidContainerRegistry * * @param data * See {@link FluidContainerData}. - * @return True if container was successfully registered; false if it already is. + * @return True if container was successfully registered; false if it already is, or an invalid parameter was passed. */ public static boolean registerFluidContainer(FluidContainerData data) { - if (isFilledContainer(data.filledContainer)) + if (isFilledContainer(data.filledContainer) || data.filledContainer == null) { return false; } + if (data.fluid == null || data.fluid.getFluid() == null) + { + FMLLog.bigWarning("Invalid registration attempt for a fluid container item %s (type %s) has occurred. The registration has been denied to prevent crashes. The mod responsible for the registration needs to correct this.", data.filledContainer.getItem().getUnlocalizedName(data.filledContainer)); + return false; + } containerFluidMap.put(new ContainerKey(data.filledContainer), data); if (data.emptyContainer != null && data.emptyContainer != NULL_EMPTYCONTAINER)