Merge branch 'miscchanges'
This commit is contained in:
commit
7d700916d9
10 changed files with 194 additions and 59 deletions
|
@ -15,6 +15,16 @@ public abstract class RenderLivingEvent extends Event
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cancelable
|
||||||
|
public static class Pre extends RenderLivingEvent
|
||||||
|
{
|
||||||
|
public Pre(EntityLivingBase entity, RendererLivingEntity renderer){ super(entity, renderer); }
|
||||||
|
}
|
||||||
|
public static class Post extends RenderLivingEvent
|
||||||
|
{
|
||||||
|
public Post(EntityLivingBase entity, RendererLivingEntity renderer){ super(entity, renderer); }
|
||||||
|
}
|
||||||
|
|
||||||
public abstract static class Specials extends RenderLivingEvent
|
public abstract static class Specials extends RenderLivingEvent
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,11 +15,11 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a base implementation for Fluid blocks.
|
* This is a base implementation for Fluid blocks.
|
||||||
*
|
*
|
||||||
* It is highly recommended that you extend this class or one of the Forge-provided child classes.
|
* It is highly recommended that you extend this class or one of the Forge-provided child classes.
|
||||||
*
|
*
|
||||||
* @author King Lemming, OvermindDL1
|
* @author King Lemming, OvermindDL1
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class BlockFluidBase extends Block implements IFluidBlock
|
public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||||
protected float quantaPerBlockFloat = 8F;
|
protected float quantaPerBlockFloat = 8F;
|
||||||
protected int density = 1;
|
protected int density = 1;
|
||||||
protected int densityDir = -1;
|
protected int densityDir = -1;
|
||||||
|
protected int temperature = 295;
|
||||||
|
|
||||||
protected int tickRate = 20;
|
protected int tickRate = 20;
|
||||||
protected int renderPass = 1;
|
protected int renderPass = 1;
|
||||||
|
@ -55,6 +56,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||||
|
|
||||||
this.fluidName = fluid.getName();
|
this.fluidName = fluid.getName();
|
||||||
this.density = fluid.density;
|
this.density = fluid.density;
|
||||||
|
this.temperature = fluid.temperature;
|
||||||
this.maxScaledLight = fluid.luminosity;
|
this.maxScaledLight = fluid.luminosity;
|
||||||
this.tickRate = fluid.viscosity / 200;
|
this.tickRate = fluid.viscosity / 200;
|
||||||
fluid.setBlockID(id);
|
fluid.setBlockID(id);
|
||||||
|
@ -78,6 +80,12 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockFluidBase setTemperature(int temperature)
|
||||||
|
{
|
||||||
|
this.temperature = temperature;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public BlockFluidBase setTickRate(int tickRate)
|
public BlockFluidBase setTickRate(int tickRate)
|
||||||
{
|
{
|
||||||
if (tickRate <= 0) tickRate = 20;
|
if (tickRate <= 0) tickRate = 20;
|
||||||
|
@ -121,7 +129,15 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
if (this.density > getDensity(world, x, y, z))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,7 +172,15 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Block.blocksList[bId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
Block.blocksList[bId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
||||||
return true;
|
|
||||||
|
if (this.density > getDensity(world, x, y, z))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract int getQuantaValue(IBlockAccess world, int x, int y, int z);
|
public abstract int getQuantaValue(IBlockAccess world, int x, int y, int z);
|
||||||
|
@ -272,7 +296,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||||
int lightUpBase = lightUp & 255;
|
int lightUpBase = lightUp & 255;
|
||||||
int lightThisExt = lightThis >> 16 & 255;
|
int lightThisExt = lightThis >> 16 & 255;
|
||||||
int lightUpExt = lightUp >> 16 & 255;
|
int lightUpExt = lightUp >> 16 & 255;
|
||||||
return (lightThisBase > lightUpBase ? lightThisBase : lightUpBase) |
|
return (lightThisBase > lightUpBase ? lightThisBase : lightUpBase) |
|
||||||
((lightThisExt > lightUpExt ? lightThisExt : lightUpExt) << 16);
|
((lightThisExt > lightUpExt ? lightThisExt : lightUpExt) << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,11 +327,21 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||||
}
|
}
|
||||||
return ((BlockFluidBase)block).density;
|
return ((BlockFluidBase)block).density;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final int getTemperature(IBlockAccess world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||||
|
if (!(block instanceof BlockFluidBase))
|
||||||
|
{
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
return ((BlockFluidBase)block).temperature;
|
||||||
|
}
|
||||||
|
|
||||||
public static double getFlowDirection(IBlockAccess world, int x, int y, int z)
|
public static double getFlowDirection(IBlockAccess world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||||
if (!(block instanceof BlockFluidBase))
|
if (!world.getBlockMaterial(x, y, z).isLiquid())
|
||||||
{
|
{
|
||||||
return -1000.0;
|
return -1000.0;
|
||||||
}
|
}
|
||||||
|
@ -381,7 +415,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||||
|
|
||||||
if (world.getBlockId(x, y + 1, z) == blockID)
|
if (world.getBlockId(x, y + 1, z) == blockID)
|
||||||
{
|
{
|
||||||
boolean flag =
|
boolean flag =
|
||||||
isBlockSolid(world, x, y, z - 1, 2) ||
|
isBlockSolid(world, x, y, z - 1, 2) ||
|
||||||
isBlockSolid(world, x, y, z + 1, 3) ||
|
isBlockSolid(world, x, y, z + 1, 3) ||
|
||||||
isBlockSolid(world, x - 1, y, z, 4) ||
|
isBlockSolid(world, x - 1, y, z, 4) ||
|
||||||
|
@ -390,7 +424,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||||
isBlockSolid(world, x, y + 1, z + 1, 3) ||
|
isBlockSolid(world, x, y + 1, z + 1, 3) ||
|
||||||
isBlockSolid(world, x - 1, y + 1, z, 4) ||
|
isBlockSolid(world, x - 1, y + 1, z, 4) ||
|
||||||
isBlockSolid(world, x + 1, y + 1, z, 5);
|
isBlockSolid(world, x + 1, y + 1, z, 5);
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
vec = vec.normalize().addVector(0.0D, -6.0D, 0.0D);
|
vec = vec.normalize().addVector(0.0D, -6.0D, 0.0D);
|
||||||
|
|
|
@ -10,11 +10,11 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a fluid block implementation which emulates vanilla Minecraft fluid behavior.
|
* This is a fluid block implementation which emulates vanilla Minecraft fluid behavior.
|
||||||
*
|
*
|
||||||
* It is highly recommended that you use/extend this class for "classic" fluid blocks.
|
* It is highly recommended that you use/extend this class for "classic" fluid blocks.
|
||||||
*
|
*
|
||||||
* @author King Lemming
|
* @author King Lemming
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BlockFluidClassic extends BlockFluidBase
|
public class BlockFluidClassic extends BlockFluidBase
|
||||||
{
|
{
|
||||||
|
@ -92,8 +92,8 @@ public class BlockFluidClassic extends BlockFluidBase
|
||||||
{
|
{
|
||||||
int y2 = y - densityDir;
|
int y2 = y - densityDir;
|
||||||
|
|
||||||
if (world.getBlockId(x, y2, z ) == blockID ||
|
if (world.getBlockId(x, y2, z ) == blockID ||
|
||||||
world.getBlockId(x - 1, y2, z ) == blockID ||
|
world.getBlockId(x - 1, y2, z ) == blockID ||
|
||||||
world.getBlockId(x + 1, y2, z ) == blockID ||
|
world.getBlockId(x + 1, y2, z ) == blockID ||
|
||||||
world.getBlockId(x, y2, z - 1) == blockID ||
|
world.getBlockId(x, y2, z - 1) == blockID ||
|
||||||
world.getBlockId(x, y2, z + 1) == blockID)
|
world.getBlockId(x, y2, z + 1) == blockID)
|
||||||
|
@ -128,9 +128,10 @@ public class BlockFluidClassic extends BlockFluidBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (quantaRemaining > quantaPerBlock)
|
// This is a "source" block, set meta to zero, and send a server only update
|
||||||
|
else if (quantaRemaining >= quantaPerBlock)
|
||||||
{
|
{
|
||||||
world.setBlockMetadataWithNotify(x, y, z, 0, 3);
|
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flow vertically if possible
|
// Flow vertically if possible
|
||||||
|
@ -226,7 +227,7 @@ public class BlockFluidClassic extends BlockFluidBase
|
||||||
int cost = 1000;
|
int cost = 1000;
|
||||||
for (int adjSide = 0; adjSide < 4; adjSide++)
|
for (int adjSide = 0; adjSide < 4; adjSide++)
|
||||||
{
|
{
|
||||||
if ((adjSide == 0 && side == 1) ||
|
if ((adjSide == 0 && side == 1) ||
|
||||||
(adjSide == 1 && side == 0) ||
|
(adjSide == 1 && side == 0) ||
|
||||||
(adjSide == 2 && side == 3) ||
|
(adjSide == 2 && side == 3) ||
|
||||||
(adjSide == 3 && side == 2))
|
(adjSide == 3 && side == 2))
|
||||||
|
@ -302,7 +303,15 @@ public class BlockFluidClassic extends BlockFluidBase
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
if (this.density > getDensity(world, x, y, z))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getLargerQuanta(IBlockAccess world, int x, int y, int z, int compare)
|
protected int getLargerQuanta(IBlockAccess world, int x, int y, int z, int compare)
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
package net.minecraftforge.fluids;
|
package net.minecraftforge.fluids;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.util.Icon;
|
import net.minecraft.util.Icon;
|
||||||
|
@ -15,21 +18,21 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minecraft Forge Fluid Implementation
|
* Minecraft Forge Fluid Implementation
|
||||||
*
|
*
|
||||||
* This class is a fluid (liquid or gas) equivalent to "Item." It describes the nature of a fluid
|
* This class is a fluid (liquid or gas) equivalent to "Item." It describes the nature of a fluid
|
||||||
* and contains its general properties.
|
* and contains its general properties.
|
||||||
*
|
*
|
||||||
* These properties do not have inherent gameplay mechanics - they are provided so that mods may
|
* These properties do not have inherent gameplay mechanics - they are provided so that mods may
|
||||||
* choose to take advantage of them.
|
* choose to take advantage of them.
|
||||||
*
|
*
|
||||||
* Fluid implementations are not required to actively use these properties, nor are objects
|
* Fluid implementations are not required to actively use these properties, nor are objects
|
||||||
* interfacing with fluids required to make use of them, but it is encouraged.
|
* interfacing with fluids required to make use of them, but it is encouraged.
|
||||||
*
|
*
|
||||||
* The default values can be used as a reference point for mods adding fluids such as oil or heavy
|
* The default values can be used as a reference point for mods adding fluids such as oil or heavy
|
||||||
* water.
|
* water.
|
||||||
*
|
*
|
||||||
* @author King Lemming
|
* @author King Lemming
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Fluid
|
public class Fluid
|
||||||
{
|
{
|
||||||
|
@ -45,7 +48,7 @@ public class Fluid
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The light level emitted by this fluid.
|
* The light level emitted by this fluid.
|
||||||
*
|
*
|
||||||
* Default value is 0, as most fluids do not actively emit light.
|
* Default value is 0, as most fluids do not actively emit light.
|
||||||
*/
|
*/
|
||||||
protected int luminosity = 0;
|
protected int luminosity = 0;
|
||||||
|
@ -53,31 +56,39 @@ public class Fluid
|
||||||
/**
|
/**
|
||||||
* Density of the fluid - completely arbitrary; negative density indicates that the fluid is
|
* Density of the fluid - completely arbitrary; negative density indicates that the fluid is
|
||||||
* lighter than air.
|
* lighter than air.
|
||||||
*
|
*
|
||||||
* Default value is approximately the real-life density of water in kg/m^3.
|
* Default value is approximately the real-life density of water in kg/m^3.
|
||||||
*/
|
*/
|
||||||
protected int density = 1000;
|
protected int density = 1000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temperature of the fluid - completely arbitrary; higher temperature indicates that the fluid is
|
||||||
|
* hotter than air.
|
||||||
|
*
|
||||||
|
* Default value is approximately the real-life room temperature of water in degrees Kelvin.
|
||||||
|
*/
|
||||||
|
protected int temperature = 295;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Viscosity ("thickness") of the fluid - completely arbitrary; negative values are not
|
* Viscosity ("thickness") of the fluid - completely arbitrary; negative values are not
|
||||||
* permissible.
|
* permissible.
|
||||||
*
|
*
|
||||||
* Default value is approximately the real-life density of water in m/s^2 (x10^-3).
|
* Default value is approximately the real-life density of water in m/s^2 (x10^-3).
|
||||||
*/
|
*/
|
||||||
protected int viscosity = 1000;
|
protected int viscosity = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This indicates if the fluid is gaseous.
|
* This indicates if the fluid is gaseous.
|
||||||
*
|
*
|
||||||
* Useful for rendering the fluid in containers and the world.
|
* Useful for rendering the fluid in containers and the world.
|
||||||
*
|
*
|
||||||
* Generally this is associated with negative density fluids.
|
* Generally this is associated with negative density fluids.
|
||||||
*/
|
*/
|
||||||
protected boolean isGaseous;
|
protected boolean isGaseous;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there is a Block implementation of the Fluid, the BlockID is linked here.
|
* If there is a Block implementation of the Fluid, the BlockID is linked here.
|
||||||
*
|
*
|
||||||
* The default value of -1 should remain for any Fluid without a Block implementation.
|
* The default value of -1 should remain for any Fluid without a Block implementation.
|
||||||
*/
|
*/
|
||||||
protected int blockID = -1;
|
protected int blockID = -1;
|
||||||
|
@ -132,6 +143,12 @@ public class Fluid
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Fluid setTemperature(int temperature)
|
||||||
|
{
|
||||||
|
this.temperature = temperature;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Fluid setViscosity(int viscosity)
|
public Fluid setViscosity(int viscosity)
|
||||||
{
|
{
|
||||||
this.viscosity = viscosity;
|
this.viscosity = viscosity;
|
||||||
|
@ -200,6 +217,11 @@ public class Fluid
|
||||||
return this.density;
|
return this.density;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final int getTemperature()
|
||||||
|
{
|
||||||
|
return this.temperature;
|
||||||
|
}
|
||||||
|
|
||||||
public final int getViscosity()
|
public final int getViscosity()
|
||||||
{
|
{
|
||||||
return this.viscosity;
|
return this.viscosity;
|
||||||
|
@ -252,6 +274,7 @@ public class Fluid
|
||||||
/* Stack-based Accessors */
|
/* Stack-based Accessors */
|
||||||
public int getLuminosity(FluidStack stack){ return getLuminosity(); }
|
public int getLuminosity(FluidStack stack){ return getLuminosity(); }
|
||||||
public int getDensity(FluidStack stack){ return getDensity(); }
|
public int getDensity(FluidStack stack){ return getDensity(); }
|
||||||
|
public int getTemperature(FluidStack stack){ return getTemperature(); }
|
||||||
public int getViscosity(FluidStack stack){ return getViscosity(); }
|
public int getViscosity(FluidStack stack){ return getViscosity(); }
|
||||||
public boolean isGaseous(FluidStack stack){ return isGaseous(); }
|
public boolean isGaseous(FluidStack stack){ return isGaseous(); }
|
||||||
public int getColor(FluidStack stack){ return getColor(); }
|
public int getColor(FluidStack stack){ return getColor(); }
|
||||||
|
@ -259,8 +282,25 @@ public class Fluid
|
||||||
/* World-based Accessors */
|
/* World-based Accessors */
|
||||||
public int getLuminosity(World world, int x, int y, int z){ return getLuminosity(); }
|
public int getLuminosity(World world, int x, int y, int z){ return getLuminosity(); }
|
||||||
public int getDensity(World world, int x, int y, int z){ return getDensity(); }
|
public int getDensity(World world, int x, int y, int z){ return getDensity(); }
|
||||||
|
public int getTemperature(World world, int x, int y, int z){ return getTemperature(); }
|
||||||
public int getViscosity(World world, int x, int y, int z){ return getViscosity(); }
|
public int getViscosity(World world, int x, int y, int z){ return getViscosity(); }
|
||||||
public boolean isGaseous(World world, int x, int y, int z){ return isGaseous(); }
|
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 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(); }
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,9 @@ import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles Fluid registrations. Fluids MUST be registered in order to function.
|
* Handles Fluid registrations. Fluids MUST be registered in order to function.
|
||||||
*
|
*
|
||||||
* @author King Lemming, CovertJaguar (LiquidDictionary)
|
* @author King Lemming, CovertJaguar (LiquidDictionary)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class FluidRegistry
|
public abstract class FluidRegistry
|
||||||
{
|
{
|
||||||
|
@ -25,8 +25,8 @@ public abstract class FluidRegistry
|
||||||
static HashMap<String, Fluid> fluids = new HashMap();
|
static HashMap<String, Fluid> fluids = new HashMap();
|
||||||
static BiMap<String, Integer> fluidIDs = HashBiMap.create();
|
static BiMap<String, Integer> fluidIDs = HashBiMap.create();
|
||||||
|
|
||||||
public static final Fluid WATER = new Fluid("water").setBlockID(Block.waterStill.blockID);
|
public static final Fluid WATER = new Fluid("water").setBlockID(Block.waterStill.blockID).setUnlocalizedName(Block.waterStill.getUnlocalizedName());
|
||||||
public static final Fluid LAVA = new Fluid("lava").setBlockID(Block.lavaStill.blockID).setLuminosity(15).setDensity(3000).setViscosity(6000);
|
public static final Fluid LAVA = new Fluid("lava").setBlockID(Block.lavaStill.blockID).setLuminosity(15).setDensity(3000).setViscosity(6000).setUnlocalizedName(Block.lavaStill.getUnlocalizedName());
|
||||||
|
|
||||||
public static int renderIdFluid = -1;
|
public static int renderIdFluid = -1;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public abstract class FluidRegistry
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a new Fluid. If a fluid with the same name already exists, registration is denied.
|
* Register a new Fluid. If a fluid with the same name already exists, registration is denied.
|
||||||
*
|
*
|
||||||
* @param fluid
|
* @param fluid
|
||||||
* The fluid to register.
|
* The fluid to register.
|
||||||
* @return True if the fluid was successfully registered; false if there is a name clash.
|
* @return True if the fluid was successfully registered; false if there is a name clash.
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
|
|
||||||
package net.minecraftforge.fluids;
|
package net.minecraftforge.fluids;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ItemStack substitute for Fluids.
|
* ItemStack substitute for Fluids.
|
||||||
*
|
*
|
||||||
* NOTE: Equality is based on the Fluid, not the amount. Use
|
* NOTE: Equality is based on the Fluid, not the amount. Use
|
||||||
* {@link #isFluidStackIdentical(FluidStack)} to determine if FluidID, Amount and NBT Tag are all
|
* {@link #isFluidStackIdentical(FluidStack)} to determine if FluidID, Amount and NBT Tag are all
|
||||||
* equal.
|
* equal.
|
||||||
*
|
*
|
||||||
* @author King Lemming, SirSengir (LiquidStack)
|
* @author King Lemming, SirSengir (LiquidStack)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FluidStack
|
public class FluidStack
|
||||||
{
|
{
|
||||||
|
@ -53,16 +55,31 @@ public class FluidStack
|
||||||
*/
|
*/
|
||||||
public static FluidStack loadFluidStackFromNBT(NBTTagCompound nbt)
|
public static FluidStack loadFluidStackFromNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
if (nbt == null || FluidRegistry.getFluid(nbt.getString("FluidName")) == null)
|
if (nbt == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
FluidStack stack = new FluidStack(FluidRegistry.getFluidID(nbt.getString("FluidName")), nbt.getInteger("Amount"));
|
String fluidName = nbt.getString("FluidName");
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
FluidStack stack = new FluidStack(FluidRegistry.getFluidID(fluidName), nbt.getInteger("Amount"));
|
||||||
|
|
||||||
if (nbt.hasKey("Tag"))
|
if (nbt.hasKey("Tag"))
|
||||||
{
|
{
|
||||||
stack.tag = nbt.getCompoundTag("Tag");
|
stack.tag = nbt.getCompoundTag("Tag");
|
||||||
}
|
}
|
||||||
|
else if (nbt.hasKey("extra"))
|
||||||
|
{
|
||||||
|
stack.tag = nbt.getCompoundTag("extra");
|
||||||
|
}
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +110,7 @@ public class FluidStack
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the FluidIDs and NBT Tags are equal. This does not check amounts.
|
* Determines if the FluidIDs and NBT Tags are equal. This does not check amounts.
|
||||||
*
|
*
|
||||||
* @param other
|
* @param other
|
||||||
* The FluidStack for comparison
|
* The FluidStack for comparison
|
||||||
* @return true if the Fluids (IDs and NBT Tags) are the same
|
* @return true if the Fluids (IDs and NBT Tags) are the same
|
||||||
|
@ -118,7 +135,7 @@ public class FluidStack
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the Fluids are equal and this stack is larger.
|
* Determines if the Fluids are equal and this stack is larger.
|
||||||
*
|
*
|
||||||
* @param other
|
* @param other
|
||||||
* @return true if this FluidStack contains the other FluidStack (same fluid and >= amount)
|
* @return true if this FluidStack contains the other FluidStack (same fluid and >= amount)
|
||||||
*/
|
*/
|
||||||
|
@ -129,7 +146,7 @@ public class FluidStack
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the FluidIDs, Amounts, and NBT Tags are all equal.
|
* Determines if the FluidIDs, Amounts, and NBT Tags are all equal.
|
||||||
*
|
*
|
||||||
* @param other
|
* @param other
|
||||||
* - the FluidStack for comparison
|
* - the FluidStack for comparison
|
||||||
* @return true if the two FluidStacks are exactly the same
|
* @return true if the two FluidStacks are exactly the same
|
||||||
|
@ -142,7 +159,7 @@ public class FluidStack
|
||||||
/**
|
/**
|
||||||
* Determines if the FluidIDs and NBT Tags are equal compared to a registered container
|
* Determines if the FluidIDs and NBT Tags are equal compared to a registered container
|
||||||
* ItemStack. This does not check amounts.
|
* ItemStack. This does not check amounts.
|
||||||
*
|
*
|
||||||
* @param other
|
* @param other
|
||||||
* The ItemStack for comparison
|
* The ItemStack for comparison
|
||||||
* @return true if the Fluids (IDs and NBT Tags) are the same
|
* @return true if the Fluids (IDs and NBT Tags) are the same
|
||||||
|
@ -170,7 +187,7 @@ public class FluidStack
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default equality comparison for a FluidStack. Same functionality as isFluidEqual().
|
* Default equality comparison for a FluidStack. Same functionality as isFluidEqual().
|
||||||
*
|
*
|
||||||
* This is included for use in data structures.
|
* This is included for use in data structures.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package net.minecraftforge.fluids;
|
package net.minecraftforge.fluids;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -29,12 +28,14 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
|
||||||
{
|
{
|
||||||
float total = 0;
|
float total = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
float end = 0;
|
||||||
|
|
||||||
for (int i = 0; i < flow.length; i++)
|
for (int i = 0; i < flow.length; i++)
|
||||||
{
|
{
|
||||||
if (flow[i] >= 0.875F)
|
if (flow[i] >= 0.875F && end != 1F)
|
||||||
{
|
{
|
||||||
return flow[i];
|
end = flow[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flow[i] >= 0)
|
if (flow[i] >= 0)
|
||||||
|
@ -43,14 +44,18 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return total / count;
|
|
||||||
|
if (end == 0)
|
||||||
|
end = total / count;
|
||||||
|
|
||||||
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getFluidHeightForRender(IBlockAccess world, int x, int y, int z, BlockFluidBase block)
|
public float getFluidHeightForRender(IBlockAccess world, int x, int y, int z, BlockFluidBase block)
|
||||||
{
|
{
|
||||||
if (world.getBlockId(x, y, z) == block.blockID)
|
if (world.getBlockId(x, y, z) == block.blockID)
|
||||||
{
|
{
|
||||||
if (world.getBlockId(x, y - block.densityDir, z) == block.blockID)
|
if (world.getBlockMaterial(x, y - block.densityDir, z).isLiquid())
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -199,12 +204,12 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
|
||||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y - 1, z));
|
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y - 1, z));
|
||||||
if (!rises)
|
if (!rises)
|
||||||
{
|
{
|
||||||
tessellator.setColorOpaque_F(LIGHT_Y_NEG, LIGHT_Y_NEG, LIGHT_Y_NEG);
|
tessellator.setColorOpaque_F(LIGHT_Y_NEG * red, LIGHT_Y_NEG * green, LIGHT_Y_NEG * blue);
|
||||||
renderer.renderFaceYNeg(block, x, y + RENDER_OFFSET, z, block.getIcon(0, bMeta));
|
renderer.renderFaceYNeg(block, x, y + RENDER_OFFSET, z, block.getIcon(0, bMeta));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tessellator.setColorOpaque_F(LIGHT_Y_POS, LIGHT_Y_POS, LIGHT_Y_POS);
|
tessellator.setColorOpaque_F(LIGHT_Y_POS * red, LIGHT_Y_POS * green, LIGHT_Y_POS * blue);
|
||||||
renderer.renderFaceYPos(block, x, y + RENDER_OFFSET, z, block.getIcon(1, bMeta));
|
renderer.renderFaceYPos(block, x, y + RENDER_OFFSET, z, block.getIcon(1, bMeta));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,4 +324,4 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
|
||||||
{
|
{
|
||||||
return FluidRegistry.renderIdFluid;
|
return FluidRegistry.renderIdFluid;
|
||||||
}
|
}
|
||||||
}
|
}
|
2
fml
2
fml
|
@ -1 +1 @@
|
||||||
Subproject commit 10b16d32da4b7c32b15e69cf1c636505ebbe2540
|
Subproject commit 1d84e8063e9d0dc73928dba006e6001201285cad
|
|
@ -33,19 +33,23 @@
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
@@ -347,6 +357,12 @@
|
@@ -347,8 +357,14 @@
|
||||||
float f2 = (float)par8Vec3.zCoord - (float)par6;
|
float f2 = (float)par8Vec3.zCoord - (float)par6;
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
int i1;
|
int i1;
|
||||||
|
-
|
||||||
|
- if (!par1EntityPlayer.isSneaking() || par1EntityPlayer.getHeldItem() == null)
|
||||||
+ if (par3ItemStack != null &&
|
+ if (par3ItemStack != null &&
|
||||||
+ par3ItemStack.getItem() != null &&
|
+ par3ItemStack.getItem() != null &&
|
||||||
+ par3ItemStack.getItem().onItemUseFirst(par3ItemStack, par1EntityPlayer, par2World, par4, par5, par6, par7, f, f1, f2))
|
+ par3ItemStack.getItem().onItemUseFirst(par3ItemStack, par1EntityPlayer, par2World, par4, par5, par6, par7, f, f1, f2))
|
||||||
+ {
|
+ {
|
||||||
+ return true;
|
+ return true;
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
if (!par1EntityPlayer.isSneaking() || par1EntityPlayer.getHeldItem() == null)
|
+ if (!par1EntityPlayer.isSneaking() || (par1EntityPlayer.getHeldItem() == null || par1EntityPlayer.getHeldItem().getItem().shouldPassSneakingClickToBlock(par2World, par4, par5, par6)))
|
||||||
{
|
{
|
||||||
|
i1 = par2World.getBlockId(par4, par5, par6);
|
||||||
|
|
||||||
@@ -389,7 +405,15 @@
|
@@ -389,7 +405,15 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -20,7 +20,23 @@
|
||||||
|
|
||||||
public RendererLivingEntity(ModelBase par1ModelBase, float par2)
|
public RendererLivingEntity(ModelBase par1ModelBase, float par2)
|
||||||
{
|
{
|
||||||
@@ -442,12 +448,13 @@
|
@@ -68,6 +74,7 @@
|
||||||
|
|
||||||
|
public void func_130000_a(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, float par8, float par9)
|
||||||
|
{
|
||||||
|
+ if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(par1EntityLivingBase, this))) return;
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||||
|
this.mainModel.onGround = this.renderSwingProgress(par1EntityLivingBase, par9);
|
||||||
|
@@ -277,6 +284,7 @@
|
||||||
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
this.passSpecialRender(par1EntityLivingBase, par2, par4, par6);
|
||||||
|
+ MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(par1EntityLivingBase, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@@ -442,12 +450,13 @@
|
||||||
*/
|
*/
|
||||||
protected void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6)
|
protected void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +51,7 @@
|
||||||
|
|
||||||
if (d3 < (double)(f2 * f2))
|
if (d3 < (double)(f2 * f2))
|
||||||
{
|
{
|
||||||
@@ -491,6 +498,7 @@
|
@@ -491,6 +500,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue