Add a translation map for looking up legacy liquid names to convert

to new fluid names.
This commit is contained in:
cpw 2013-07-28 01:06:16 +02:00
parent 31bd8d438d
commit b317d10ade
2 changed files with 33 additions and 12 deletions

View file

@ -2,6 +2,9 @@
package net.minecraftforge.fluids;
import java.util.Locale;
import java.util.Map;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.util.Icon;
@ -263,4 +266,20 @@ public class Fluid
public boolean isGaseous(World world, int x, int y, int z){ return isGaseous(); }
public int getColor(World world, int x, int y, int z){ return getColor(); }
public Icon getIcon(World world, int x, int y, int z){ return getIcon(); }
private static Map<String, String> legacyNames = Maps.newHashMap();
static String convertLegacyName(String fluidName)
{
return fluidName != null && legacyNames.containsKey(fluidName) ? legacyNames.get(fluidName) : fluidName;
}
/**
* Register a legacy liquid name with the Fluids system
* @param legacyName The legacy name to recognize
* @param canonicalName The canonical fluid name it will become
*/
public static void registerLegacyName(String legacyName, String canonicalName)
{
legacyNames.put(legacyName.toLowerCase(Locale.ENGLISH), canonicalName);
}
}

View file

@ -63,7 +63,9 @@ public class FluidStack
if (fluidName == null)
{
fluidName = nbt.hasKey("LiquidName") ? nbt.getString("LiquidName").toLowerCase(Locale.ENGLISH) : null;
fluidName = Fluid.convertLegacyName(fluidName);
}
if (fluidName ==null || FluidRegistry.getFluid(fluidName) == null)
{
return null;