Cleanup Fluid deprecations stuff.
This commit is contained in:
parent
22e99a2cff
commit
b4dc15a9cb
|
@ -13,7 +13,7 @@ public class FMLForgePlugin implements IFMLLoadingPlugin
|
|||
@Override
|
||||
public String[] getASMTransformerClass()
|
||||
{
|
||||
return new String[] { "net.minecraftforge.classloading.FluidIdTransformer" };
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
package net.minecraftforge.classloading;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;;
|
||||
|
||||
public class FluidIdTransformer implements IClassTransformer {
|
||||
private static final String FLUID_TYPE = "net/minecraftforge/fluids/FluidStack";
|
||||
private static final String GETID_NAME = "getFluidID";
|
||||
private static final String LEGACY_FIELDNAME = "fluidID";
|
||||
private static final String GETID_DESC = "()I";
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null)
|
||||
return null;
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader classReader = new ClassReader(basicClass);
|
||||
classReader.accept(classNode, 0);
|
||||
|
||||
for (MethodNode m: classNode.methods)
|
||||
{
|
||||
for (ListIterator<AbstractInsnNode> it = m.instructions.iterator(); it.hasNext(); )
|
||||
{
|
||||
AbstractInsnNode insnNode = it.next();
|
||||
if (insnNode.getType() == AbstractInsnNode.FIELD_INSN)
|
||||
{
|
||||
FieldInsnNode fi = (FieldInsnNode)insnNode;
|
||||
if (FLUID_TYPE.equals(fi.owner) && LEGACY_FIELDNAME.equals(fi.name) && fi.getOpcode() == Opcodes.GETFIELD)
|
||||
{
|
||||
FMLLog.fine("Method %s.%s%s: Replacing GETFIELD fluidID with INVOKEVIRTUAL getFluidID", name, m.name, m.desc);
|
||||
it.remove();
|
||||
MethodInsnNode replace = new MethodInsnNode(Opcodes.INVOKEVIRTUAL, FLUID_TYPE, GETID_NAME, GETID_DESC, false);
|
||||
it.add(replace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
classNode.accept(writer);
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
}
|
|
@ -300,7 +300,6 @@ public class ForgeHooksClient
|
|||
{
|
||||
MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Pre(map));
|
||||
ModelLoader.White.instance.register(map);
|
||||
FluidRegistry.onTextureStitchedPre(map);
|
||||
}
|
||||
|
||||
public static void onTextureStitchedPost(TextureMap map)
|
||||
|
|
|
@ -42,15 +42,6 @@ public class Fluid
|
|||
/** The unlocalized name of this fluid. */
|
||||
protected String unlocalizedName;
|
||||
|
||||
/**
|
||||
* The Icons for this fluid.
|
||||
* @deprecated use ResourceLocation-based ones instead.
|
||||
*/
|
||||
@Deprecated
|
||||
protected TextureAtlasSprite stillIcon;
|
||||
@Deprecated
|
||||
protected TextureAtlasSprite flowingIcon;
|
||||
|
||||
protected final ResourceLocation still;
|
||||
protected final ResourceLocation flowing;
|
||||
|
||||
|
@ -112,15 +103,6 @@ public class Fluid
|
|||
*/
|
||||
protected Block block = null;
|
||||
|
||||
/**
|
||||
* @deprecated use the constructor with texture locations.
|
||||
*/
|
||||
@Deprecated
|
||||
public Fluid(String fluidName)
|
||||
{
|
||||
this(fluidName, null, null);
|
||||
}
|
||||
|
||||
public Fluid(String fluidName, ResourceLocation still, ResourceLocation flowing)
|
||||
{
|
||||
this.fluidName = fluidName.toLowerCase(Locale.ENGLISH);
|
||||
|
@ -209,15 +191,6 @@ public class Fluid
|
|||
* Returns the localized name of this fluid.
|
||||
*/
|
||||
public String getLocalizedName(FluidStack stack)
|
||||
{
|
||||
return getLocalizedName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the FluidStack sensitive version above
|
||||
*/
|
||||
@Deprecated
|
||||
public String getLocalizedName()
|
||||
{
|
||||
String s = this.getUnlocalizedName();
|
||||
return s == null ? "" : StatCollector.translateToLocal(s);
|
||||
|
@ -239,14 +212,6 @@ public class Fluid
|
|||
return "fluid." + this.unlocalizedName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0 for "/terrain.png". ALL FLUID TEXTURES MUST BE ON THIS SHEET.
|
||||
*/
|
||||
public final int getSpriteNumber()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Default Accessors */
|
||||
public final int getLuminosity()
|
||||
{
|
||||
|
@ -293,47 +258,6 @@ public class Fluid
|
|||
return flowing;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public final Fluid setStillIcon(TextureAtlasSprite stillIcon)
|
||||
{
|
||||
this.stillIcon = stillIcon;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public final Fluid setFlowingIcon(TextureAtlasSprite flowingIcon)
|
||||
{
|
||||
this.flowingIcon = flowingIcon;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public final Fluid setIcons(TextureAtlasSprite stillIcon, TextureAtlasSprite flowingIcon)
|
||||
{
|
||||
return this.setStillIcon(stillIcon).setFlowingIcon(flowingIcon);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public final Fluid setIcons(TextureAtlasSprite commonIcon)
|
||||
{
|
||||
return this.setStillIcon(commonIcon).setFlowingIcon(commonIcon);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public TextureAtlasSprite getIcon(){ return getStillIcon(); }
|
||||
|
||||
@Deprecated
|
||||
public TextureAtlasSprite getStillIcon()
|
||||
{
|
||||
return this.stillIcon;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public TextureAtlasSprite getFlowingIcon()
|
||||
{
|
||||
return this.flowingIcon;
|
||||
}
|
||||
|
||||
/* Stack-based Accessors */
|
||||
public int getLuminosity(FluidStack stack){ return getLuminosity(); }
|
||||
public int getDensity(FluidStack stack){ return getDensity(); }
|
||||
|
@ -342,8 +266,6 @@ public class Fluid
|
|||
public boolean isGaseous(FluidStack stack){ return isGaseous(); }
|
||||
public EnumRarity getRarity(FluidStack stack){ return getRarity(); }
|
||||
public int getColor(FluidStack stack){ return getColor(); }
|
||||
@Deprecated
|
||||
public TextureAtlasSprite getIcon(FluidStack stack){ return getIcon(); }
|
||||
public ResourceLocation getStill(FluidStack stack) { return getStill(); }
|
||||
public ResourceLocation getFlowing(FluidStack stack) { return getFlowing(); }
|
||||
|
||||
|
@ -355,8 +277,6 @@ public class Fluid
|
|||
public boolean isGaseous(World world, BlockPos pos){ return isGaseous(); }
|
||||
public EnumRarity getRarity(World world, BlockPos pos){ return getRarity(); }
|
||||
public int getColor(World world, BlockPos pos){ return getColor(); }
|
||||
@Deprecated
|
||||
public TextureAtlasSprite getIcon(World world, BlockPos pos){ return getIcon(); }
|
||||
public ResourceLocation getStill(World world, BlockPos pos) { return getStill(); }
|
||||
public ResourceLocation getFlowing(World world, BlockPos pos) { return getFlowing(); }
|
||||
|
||||
|
|
|
@ -52,20 +52,18 @@ public abstract class FluidRegistry
|
|||
|
||||
public static final Fluid WATER = new Fluid("water", new ResourceLocation("blocks/water_still"), new ResourceLocation("blocks/water_flow")) {
|
||||
@Override
|
||||
public String getLocalizedName() {
|
||||
public String getLocalizedName(FluidStack fs) {
|
||||
return StatCollector.translateToLocal("tile.water.name");
|
||||
}
|
||||
}.setBlock(Blocks.water).setUnlocalizedName(Blocks.water.getUnlocalizedName());
|
||||
|
||||
public static final Fluid LAVA = new Fluid("lava", new ResourceLocation("blocks/lava_still"), new ResourceLocation("blocks/lava_flow")) {
|
||||
@Override
|
||||
public String getLocalizedName() {
|
||||
public String getLocalizedName(FluidStack fs) {
|
||||
return StatCollector.translateToLocal("tile.lava.name");
|
||||
}
|
||||
}.setBlock(Blocks.lava).setLuminosity(15).setDensity(3000).setViscosity(6000).setTemperature(1300).setUnlocalizedName(Blocks.lava.getUnlocalizedName());
|
||||
|
||||
public static int renderIdFluid = -1;
|
||||
|
||||
static
|
||||
{
|
||||
registerFluid(WATER);
|
||||
|
@ -87,7 +85,8 @@ public abstract class FluidRegistry
|
|||
/**
|
||||
* Called by forge to load default fluid IDs from the world or from server -> client for syncing
|
||||
* DO NOT call this and expect useful behaviour.
|
||||
* @param newfluidIDs
|
||||
* @param localFluidIDs
|
||||
* @param defaultNames
|
||||
*/
|
||||
private static void loadFluidDefaults(BiMap<Fluid, Integer> localFluidIDs, Set<String> defaultNames)
|
||||
{
|
||||
|
@ -206,12 +205,6 @@ public abstract class FluidRegistry
|
|||
return fluidIDs.get(getFluid(fluidName));
|
||||
}
|
||||
|
||||
@Deprecated //Remove in 1.8.3
|
||||
public static String getFluidName(int fluidID)
|
||||
{
|
||||
return fluidNames.get(fluidID);
|
||||
}
|
||||
|
||||
public static String getFluidName(Fluid fluid)
|
||||
{
|
||||
return fluids.inverse().get(fluid);
|
||||
|
@ -242,10 +235,9 @@ public abstract class FluidRegistry
|
|||
/**
|
||||
* Returns a read-only map containing Fluid Names and their associated IDs.
|
||||
*/
|
||||
@Deprecated //Change return type to <Fluid, Integer> in 1.8.3
|
||||
public static Map<String, Integer> getRegisteredFluidIDs()
|
||||
public static Map<Fluid, Integer> getRegisteredFluidIDs()
|
||||
{
|
||||
return ImmutableMap.copyOf(fluidNames.inverse());
|
||||
return ImmutableMap.copyOf(fluidIDs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -396,21 +388,4 @@ public abstract class FluidRegistry
|
|||
fluid = fluids.get(name);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onTextureStitchedPre(TextureMap map)
|
||||
{
|
||||
for(Fluid fluid : fluids.values())
|
||||
{
|
||||
if(fluid.getStill() != null)
|
||||
{
|
||||
TextureAtlasSprite still = map.registerSprite(fluid.getStill());
|
||||
fluid.setStillIcon(still);
|
||||
}
|
||||
if(fluid.getFlowing() != null)
|
||||
{
|
||||
TextureAtlasSprite flowing = map.registerSprite(fluid.getFlowing());
|
||||
fluid.setStillIcon(flowing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,8 +22,6 @@ public class FluidStack
|
|||
* This field will be removed in 1.8. It may be incorrect after a world is loaded. Code should always
|
||||
* use {@link #getFluid()} instead. That will always reflect the correct value.
|
||||
*/
|
||||
@Deprecated
|
||||
public final Fluid fluid;
|
||||
public int amount;
|
||||
public NBTTagCompound tag;
|
||||
private RegistryDelegate<Fluid> fluidDelegate;
|
||||
|
@ -42,7 +40,6 @@ public class FluidStack
|
|||
}
|
||||
this.fluidDelegate = FluidRegistry.makeDelegate(fluid);
|
||||
this.amount = amount;
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
public FluidStack(Fluid fluid, int amount, NBTTagCompound nbt)
|
||||
|
@ -60,20 +57,6 @@ public class FluidStack
|
|||
this(stack.getFluid(), amount, stack.tag);
|
||||
}
|
||||
|
||||
// To be removed in 1.8
|
||||
@Deprecated
|
||||
public FluidStack(int fluidID, int amount)
|
||||
{
|
||||
this(FluidRegistry.getFluid(fluidID), amount);
|
||||
}
|
||||
|
||||
// To be removed in 1.8
|
||||
@Deprecated
|
||||
public FluidStack(int fluidID, int amount, NBTTagCompound nbt)
|
||||
{
|
||||
this(FluidRegistry.getFluid(fluidID), amount, nbt);
|
||||
}
|
||||
|
||||
/**
|
||||
* This provides a safe method for retrieving a FluidStack - if the Fluid is invalid, the stack
|
||||
* will return as null.
|
||||
|
@ -116,11 +99,6 @@ public class FluidStack
|
|||
return fluidDelegate.get();
|
||||
}
|
||||
|
||||
public final int getFluidID()
|
||||
{
|
||||
return FluidRegistry.getFluidID(getFluid());
|
||||
}
|
||||
|
||||
public String getLocalizedName()
|
||||
{
|
||||
return this.getFluid().getLocalizedName(this);
|
||||
|
|
Loading…
Reference in New Issue