mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Merge branch '1.7.10' - imports all the fluid fixups and other stuff from 1.7 into 1.8
Conflicts: fml/src/main/java/net/minecraftforge/fml/common/FMLCommonHandler.java fml/src/main/java/net/minecraftforge/fml/common/Loader.java patches/minecraft/net/minecraft/client/Minecraft.java.patch patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch patches/minecraft/net/minecraft/item/ItemArmor.java.patch patches/minecraft/net/minecraft/nbt/CompressedStreamTools.java.patch patches/minecraft/net/minecraft/nbt/NBTTagCompound.java.patch patches/minecraft/net/minecraft/nbt/NBTTagList.java.patch patches/minecraft/net/minecraft/world/World.java.patch patches/minecraft/net/minecraft/world/WorldProvider.java.patch src/main/java/net/minecraftforge/common/ForgeVersion.java src/main/java/net/minecraftforge/common/network/ForgeMessage.java src/main/java/net/minecraftforge/fluids/BlockFluidBase.java src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java src/main/java/net/minecraftforge/fluids/FluidRegistry.java src/main/java/net/minecraftforge/oredict/OreDictionary.java
This commit is contained in:
commit
d02636213a
25 files changed
+722
-135
No files matched your search
@@ -1,10 +1,10 @@
|
||||
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.registry.RegistryDelegate;
|
||||
|
||||
/**
|
||||
* ItemStack substitute for Fluids.
|
||||
@@ -18,25 +18,36 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
*/
|
||||
public class FluidStack
|
||||
{
|
||||
public int fluidID;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public FluidStack(Fluid fluid, int amount)
|
||||
{
|
||||
this.fluidID = fluid.getID();
|
||||
if (fluid == null)
|
||||
{
|
||||
FMLLog.bigWarning("Null fluid supplied to fluidstack. Did you try and create a stack for an unregistered fluid?");
|
||||
throw new IllegalArgumentException("Cannot create a fluidstack from a null fluid");
|
||||
}
|
||||
else if (!FluidRegistry.isFluidRegistered(fluid))
|
||||
{
|
||||
FMLLog.bigWarning("Failed attempt to create a FluidStack for an unregistered Fluid %s (type %s)", fluid.getName(), fluid.getClass().getName());
|
||||
throw new IllegalArgumentException("Cannot create a fluidstack from an unregistered fluid");
|
||||
}
|
||||
this.fluidDelegate = FluidRegistry.makeDelegate(fluid);
|
||||
this.amount = amount;
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
public FluidStack(int fluidID, int amount)
|
||||
public FluidStack(Fluid fluid, int amount, NBTTagCompound nbt)
|
||||
{
|
||||
this.fluidID = fluidID;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public FluidStack(int fluidID, int amount, NBTTagCompound nbt)
|
||||
{
|
||||
this(fluidID, amount);
|
||||
this(fluid, amount);
|
||||
|
||||
if (nbt != null)
|
||||
{
|
||||
@@ -46,7 +57,21 @@ public class FluidStack
|
||||
|
||||
public FluidStack(FluidStack stack, int amount)
|
||||
{
|
||||
this(stack.fluidID, amount, stack.tag);
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,32 +85,23 @@ public class FluidStack
|
||||
return null;
|
||||
}
|
||||
String fluidName = nbt.getString("FluidName");
|
||||
if (Strings.isNullOrEmpty(fluidName))
|
||||
{
|
||||
fluidName = nbt.hasKey("LiquidName") ? nbt.getString("LiquidName").toLowerCase(Locale.ENGLISH) : null;
|
||||
fluidName = Fluid.convertLegacyName(fluidName);
|
||||
}
|
||||
|
||||
if (fluidName ==null || FluidRegistry.getFluid(fluidName) == null)
|
||||
if (fluidName == null || FluidRegistry.getFluid(fluidName) == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
FluidStack stack = new FluidStack(FluidRegistry.getFluidID(fluidName), nbt.getInteger("Amount"));
|
||||
FluidStack stack = new FluidStack(FluidRegistry.getFluid(fluidName), nbt.getInteger("Amount"));
|
||||
|
||||
if (nbt.hasKey("Tag"))
|
||||
{
|
||||
stack.tag = nbt.getCompoundTag("Tag");
|
||||
}
|
||||
else if (nbt.hasKey("extra"))
|
||||
{
|
||||
stack.tag = nbt.getCompoundTag("extra");
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
nbt.setString("FluidName", FluidRegistry.getFluidName(fluidID));
|
||||
nbt.setString("FluidName", FluidRegistry.getFluidName(getFluid()));
|
||||
nbt.setInteger("Amount", amount);
|
||||
|
||||
if (tag != null)
|
||||
@@ -97,7 +113,12 @@ public class FluidStack
|
||||
|
||||
public final Fluid getFluid()
|
||||
{
|
||||
return FluidRegistry.getFluid(fluidID);
|
||||
return fluidDelegate.get();
|
||||
}
|
||||
|
||||
public final int getFluidID()
|
||||
{
|
||||
return FluidRegistry.getFluidID(getFluid());
|
||||
}
|
||||
|
||||
public String getLocalizedName()
|
||||
@@ -115,7 +136,7 @@ public class FluidStack
|
||||
*/
|
||||
public FluidStack copy()
|
||||
{
|
||||
return new FluidStack(fluidID, amount, tag);
|
||||
return new FluidStack(getFluid(), amount, tag);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +148,7 @@ public class FluidStack
|
||||
*/
|
||||
public boolean isFluidEqual(FluidStack other)
|
||||
{
|
||||
return other != null && fluidID == other.fluidID && isFluidStackTagEqual(other);
|
||||
return other != null && getFluid() == other.getFluid() && isFluidStackTagEqual(other);
|
||||
}
|
||||
|
||||
private boolean isFluidStackTagEqual(FluidStack other)
|
||||
@@ -192,7 +213,12 @@ public class FluidStack
|
||||
@Override
|
||||
public final int hashCode()
|
||||
{
|
||||
return fluidID;
|
||||
int code = 1;
|
||||
code = 31*code + getFluid().hashCode();
|
||||
code = 31*code + amount;
|
||||
if (tag != null)
|
||||
code = 31*code + tag.hashCode();
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user