Merge branch 'miscchanges'

This commit is contained in:
Christian 2013-08-04 22:27:55 -04:00
commit 7d700916d9
10 changed files with 194 additions and 59 deletions

View file

@ -16,6 +16,16 @@ public abstract class RenderLivingEvent extends Event
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 Specials(EntityLivingBase entity, RendererLivingEntity renderer){ super(entity, renderer); }

View file

@ -39,6 +39,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
protected float quantaPerBlockFloat = 8F;
protected int density = 1;
protected int densityDir = -1;
protected int temperature = 295;
protected int tickRate = 20;
protected int renderPass = 1;
@ -55,6 +56,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
this.fluidName = fluid.getName();
this.density = fluid.density;
this.temperature = fluid.temperature;
this.maxScaledLight = fluid.luminosity;
this.tickRate = fluid.viscosity / 200;
fluid.setBlockID(id);
@ -78,6 +80,12 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
return this;
}
public BlockFluidBase setTemperature(int temperature)
{
this.temperature = temperature;
return this;
}
public BlockFluidBase setTickRate(int tickRate)
{
if (tickRate <= 0) tickRate = 20;
@ -121,8 +129,16 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
{
return false;
}
if (this.density > getDensity(world, x, y, z))
{
return true;
}
else
{
return false;
}
}
/**
* Attempt to displace the block at (x, y, z), return true if it was displaced.
@ -156,8 +172,16 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
return false;
}
Block.blocksList[bId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
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);
@ -304,10 +328,20 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
return ((BlockFluidBase)block).density;
}
public static double getFlowDirection(IBlockAccess world, int x, int y, int z)
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)
{
Block block = Block.blocksList[world.getBlockId(x, y, z)];
if (!world.getBlockMaterial(x, y, z).isLiquid())
{
return -1000.0;
}

View file

@ -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
@ -302,8 +303,16 @@ public class BlockFluidClassic extends BlockFluidBase
{
return false;
}
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)
{

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;
@ -58,6 +61,14 @@ public class Fluid
*/
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
* permissible.
@ -132,6 +143,12 @@ public class Fluid
return this;
}
public Fluid setTemperature(int temperature)
{
this.temperature = temperature;
return this;
}
public Fluid setViscosity(int viscosity)
{
this.viscosity = viscosity;
@ -200,6 +217,11 @@ public class Fluid
return this.density;
}
public final int getTemperature()
{
return this.temperature;
}
public final int getViscosity()
{
return this.viscosity;
@ -252,6 +274,7 @@ public class Fluid
/* Stack-based Accessors */
public int getLuminosity(FluidStack stack){ return getLuminosity(); }
public int getDensity(FluidStack stack){ return getDensity(); }
public int getTemperature(FluidStack stack){ return getTemperature(); }
public int getViscosity(FluidStack stack){ return getViscosity(); }
public boolean isGaseous(FluidStack stack){ return isGaseous(); }
public int getColor(FluidStack stack){ return getColor(); }
@ -259,8 +282,25 @@ public class Fluid
/* World-based Accessors */
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 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 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

@ -25,8 +25,8 @@ public abstract class FluidRegistry
static HashMap<String, Fluid> fluids = new HashMap();
static BiMap<String, Integer> fluidIDs = HashBiMap.create();
public static final Fluid WATER = new Fluid("water").setBlockID(Block.waterStill.blockID);
public static final Fluid LAVA = new Fluid("lava").setBlockID(Block.lavaStill.blockID).setLuminosity(15).setDensity(3000).setViscosity(6000);
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).setUnlocalizedName(Block.lavaStill.getUnlocalizedName());
public static int renderIdFluid = -1;

View file

@ -1,6 +1,8 @@
package net.minecraftforge.fluids;
import java.util.Locale;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -53,16 +55,31 @@ public class FluidStack
*/
public static FluidStack loadFluidStackFromNBT(NBTTagCompound nbt)
{
if (nbt == null || FluidRegistry.getFluid(nbt.getString("FluidName")) == null)
if (nbt == 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"))
{
stack.tag = nbt.getCompoundTag("Tag");
}
else if (nbt.hasKey("extra"))
{
stack.tag = nbt.getCompoundTag("extra");
}
return stack;
}

View file

@ -1,4 +1,3 @@
package net.minecraftforge.fluids;
import net.minecraft.block.Block;
@ -30,11 +29,13 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
float total = 0;
int count = 0;
float end = 0;
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)
@ -43,14 +44,18 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
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)
{
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;
}
@ -199,12 +204,12 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y - 1, z));
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));
}
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));
}
}

2
fml

@ -1 +1 @@
Subproject commit 10b16d32da4b7c32b15e69cf1c636505ebbe2540
Subproject commit 1d84e8063e9d0dc73928dba006e6001201285cad

View file

@ -33,19 +33,23 @@
if (flag)
{
@@ -347,6 +357,12 @@
@@ -347,8 +357,14 @@
float f2 = (float)par8Vec3.zCoord - (float)par6;
boolean flag = false;
int i1;
-
- if (!par1EntityPlayer.isSneaking() || par1EntityPlayer.getHeldItem() == null)
+ if (par3ItemStack != null &&
+ par3ItemStack.getItem() != null &&
+ par3ItemStack.getItem().onItemUseFirst(par3ItemStack, par1EntityPlayer, par2World, par4, par5, par6, par7, f, f1, f2))
+ {
+ 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 @@
}
else

View file

@ -20,7 +20,23 @@
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)
{
@ -35,7 +51,7 @@
if (d3 < (double)(f2 * f2))
{
@@ -491,6 +498,7 @@
@@ -491,6 +500,7 @@
}
}
}