From a42369e0816eae321b3f5b4588fa6fea1042ef7f Mon Sep 17 00:00:00 2001 From: tommy1019 Date: Thu, 25 Jul 2013 18:38:29 -0500 Subject: [PATCH 01/18] Fluid Render Fix Formatting --- .../minecraftforge/fluids/RenderBlockFluid.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/common/net/minecraftforge/fluids/RenderBlockFluid.java b/common/net/minecraftforge/fluids/RenderBlockFluid.java index 5a0e6b180..6a065c554 100644 --- a/common/net/minecraftforge/fluids/RenderBlockFluid.java +++ b/common/net/minecraftforge/fluids/RenderBlockFluid.java @@ -1,4 +1,3 @@ - package net.minecraftforge.fluids; import net.minecraft.block.Block; @@ -29,12 +28,14 @@ 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,7 +44,11 @@ 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) @@ -319,4 +324,4 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler { return FluidRegistry.renderIdFluid; } -} +} \ No newline at end of file From f48dafda7ea20bf7fe70d66a6590b765dea7833f Mon Sep 17 00:00:00 2001 From: iChun Date: Fri, 26 Jul 2013 12:38:17 +0800 Subject: [PATCH 02/18] Add Pre and Post events for RenderLivingEvent --- .../minecraftforge/client/event/RenderLivingEvent.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/net/minecraftforge/client/event/RenderLivingEvent.java b/client/net/minecraftforge/client/event/RenderLivingEvent.java index 6c64db9c3..7b028e1f5 100644 --- a/client/net/minecraftforge/client/event/RenderLivingEvent.java +++ b/client/net/minecraftforge/client/event/RenderLivingEvent.java @@ -15,6 +15,16 @@ public abstract class RenderLivingEvent extends Event this.entity = entity; 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 { From 3e8711580e5d305d9e7474580931e7a31d85e535 Mon Sep 17 00:00:00 2001 From: iChun Date: Fri, 26 Jul 2013 12:46:52 +0800 Subject: [PATCH 03/18] Add Pre and Post events firing for RendererLivingEntity --- .../renderer/entity/RendererLivingEntity.java.patch | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch index 59d63e9a6..990032eb8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch @@ -43,3 +43,12 @@ } protected boolean func_110813_b(EntityLivingBase par1EntityLivingBase) +@@ -570,7 +578,9 @@ + */ + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { ++ MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre((EntityLivingBase)par1Entity, this)); + this.func_130000_a((EntityLivingBase)par1Entity, par2, par4, par6, par8, par9); ++ MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post((EntityLivingBase)par1Entity, this)); + } +} From fb04d108867bbdeaf030d34307f9af06d807337f Mon Sep 17 00:00:00 2001 From: iChun Date: Fri, 26 Jul 2013 12:49:14 +0800 Subject: [PATCH 04/18] if statement added --- .../client/renderer/entity/RendererLivingEntity.java.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch index 990032eb8..c0f9df38e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch @@ -47,7 +47,7 @@ */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { -+ MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre((EntityLivingBase)par1Entity, this)); ++ if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre((EntityLivingBase)par1Entity, this))) return; this.func_130000_a((EntityLivingBase)par1Entity, par2, par4, par6, par8, par9); + MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post((EntityLivingBase)par1Entity, this)); } From abdcd23d8b0c274d55dfd6b79022c95428e663aa Mon Sep 17 00:00:00 2001 From: iChun Date: Fri, 26 Jul 2013 12:51:42 +0800 Subject: [PATCH 05/18] Update RendererLivingEntity.java.patch --- .../client/renderer/entity/RendererLivingEntity.java.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch index c0f9df38e..4a92efc5f 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch @@ -43,7 +43,7 @@ } protected boolean func_110813_b(EntityLivingBase par1EntityLivingBase) -@@ -570,7 +578,9 @@ +@@ -570,6 +578,8 @@ */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { From 077e05e0ed358de6f9f6b3520714a10fc593a875 Mon Sep 17 00:00:00 2001 From: tommy1019 Date: Fri, 26 Jul 2013 16:25:40 -0500 Subject: [PATCH 06/18] Fixed fluids eating each other Fluids check for other fluids density before flowing, if their density is higher they can flow into the other fluid, if not they can't. --- .../minecraftforge/fluids/BlockFluidBase.java | 20 +++++++++++++++++-- .../fluids/BlockFluidClassic.java | 10 +++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/common/net/minecraftforge/fluids/BlockFluidBase.java b/common/net/minecraftforge/fluids/BlockFluidBase.java index 5aea68e42..a3bc54f76 100644 --- a/common/net/minecraftforge/fluids/BlockFluidBase.java +++ b/common/net/minecraftforge/fluids/BlockFluidBase.java @@ -121,7 +121,15 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock { return false; } - return true; + + if (this.density > getDensity(world, x, y, z)) + { + return true; + } + else + { + return false; + } } /** @@ -156,7 +164,15 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock return false; } 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); diff --git a/common/net/minecraftforge/fluids/BlockFluidClassic.java b/common/net/minecraftforge/fluids/BlockFluidClassic.java index ae63e2ceb..4defe7f6e 100644 --- a/common/net/minecraftforge/fluids/BlockFluidClassic.java +++ b/common/net/minecraftforge/fluids/BlockFluidClassic.java @@ -302,7 +302,15 @@ public class BlockFluidClassic extends BlockFluidBase { 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) From fd5b7359e2a8ea958e62a1e0138ea6cbb1519992 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 27 Jul 2013 00:30:54 -0700 Subject: [PATCH 07/18] Add SneakClick bypass to client --- .../client/multiplayer/PlayerControllerMP.java.patch | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch index c6c9920f7..18f79e8d5 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch @@ -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 From 8a8f5af084c1faacab815ec5309c08d4eba8c114 Mon Sep 17 00:00:00 2001 From: cpw Date: Sat, 27 Jul 2013 23:36:27 +0200 Subject: [PATCH 08/18] Fix names for water/lava fluids. Closes #689 --- common/net/minecraftforge/fluids/FluidRegistry.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/net/minecraftforge/fluids/FluidRegistry.java b/common/net/minecraftforge/fluids/FluidRegistry.java index 4eba91c67..62c86d05d 100644 --- a/common/net/minecraftforge/fluids/FluidRegistry.java +++ b/common/net/minecraftforge/fluids/FluidRegistry.java @@ -14,9 +14,9 @@ import com.google.common.collect.ImmutableMap; /** * Handles Fluid registrations. Fluids MUST be registered in order to function. - * + * * @author King Lemming, CovertJaguar (LiquidDictionary) - * + * */ public abstract class FluidRegistry { @@ -25,8 +25,8 @@ public abstract class FluidRegistry static HashMap fluids = new HashMap(); static BiMap 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; @@ -50,7 +50,7 @@ public abstract class FluidRegistry /** * Register a new Fluid. If a fluid with the same name already exists, registration is denied. - * + * * @param fluid * The fluid to register. * @return True if the fluid was successfully registered; false if there is a name clash. From 31bd8d438d58ae1f295af98385d596c500096130 Mon Sep 17 00:00:00 2001 From: cpw Date: Sun, 28 Jul 2013 00:53:23 +0200 Subject: [PATCH 09/18] Add support for loading legacy liquid stacks as new fluid stacks. Requires having been written with the "liquidname" code from forge 1.5.x --- .../net/minecraftforge/fluids/FluidStack.java | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/common/net/minecraftforge/fluids/FluidStack.java b/common/net/minecraftforge/fluids/FluidStack.java index 99615501b..22ceed9ee 100644 --- a/common/net/minecraftforge/fluids/FluidStack.java +++ b/common/net/minecraftforge/fluids/FluidStack.java @@ -1,18 +1,20 @@ package net.minecraftforge.fluids; +import java.util.Locale; + import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; /** * ItemStack substitute for Fluids. - * + * * NOTE: Equality is based on the Fluid, not the amount. Use * {@link #isFluidStackIdentical(FluidStack)} to determine if FluidID, Amount and NBT Tag are all * equal. - * + * * @author King Lemming, SirSengir (LiquidStack) - * + * */ public class FluidStack { @@ -53,16 +55,29 @@ 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; + } + 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; } @@ -93,7 +108,7 @@ public class FluidStack /** * Determines if the FluidIDs and NBT Tags are equal. This does not check amounts. - * + * * @param other * The FluidStack for comparison * @return true if the Fluids (IDs and NBT Tags) are the same @@ -118,7 +133,7 @@ public class FluidStack /** * Determines if the Fluids are equal and this stack is larger. - * + * * @param other * @return true if this FluidStack contains the other FluidStack (same fluid and >= amount) */ @@ -129,7 +144,7 @@ public class FluidStack /** * Determines if the FluidIDs, Amounts, and NBT Tags are all equal. - * + * * @param other * - the FluidStack for comparison * @return true if the two FluidStacks are exactly the same @@ -142,7 +157,7 @@ public class FluidStack /** * Determines if the FluidIDs and NBT Tags are equal compared to a registered container * ItemStack. This does not check amounts. - * + * * @param other * The ItemStack for comparison * @return true if the Fluids (IDs and NBT Tags) are the same @@ -170,7 +185,7 @@ public class FluidStack /** * Default equality comparison for a FluidStack. Same functionality as isFluidEqual(). - * + * * This is included for use in data structures. */ @Override From b317d10ade2822f55ebf08905d6dd09ea37e78c8 Mon Sep 17 00:00:00 2001 From: cpw Date: Sun, 28 Jul 2013 01:06:16 +0200 Subject: [PATCH 10/18] Add a translation map for looking up legacy liquid names to convert to new fluid names. --- common/net/minecraftforge/fluids/Fluid.java | 43 +++++++++++++------ .../net/minecraftforge/fluids/FluidStack.java | 2 + 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/common/net/minecraftforge/fluids/Fluid.java b/common/net/minecraftforge/fluids/Fluid.java index b7c6f9147..8fa1e755e 100644 --- a/common/net/minecraftforge/fluids/Fluid.java +++ b/common/net/minecraftforge/fluids/Fluid.java @@ -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; @@ -15,21 +18,21 @@ import cpw.mods.fml.relauncher.SideOnly; /** * Minecraft Forge Fluid Implementation - * + * * This class is a fluid (liquid or gas) equivalent to "Item." It describes the nature of a fluid * and contains its general properties. - * + * * These properties do not have inherent gameplay mechanics - they are provided so that mods may * choose to take advantage of them. - * + * * 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. - * + * * The default values can be used as a reference point for mods adding fluids such as oil or heavy * water. - * + * * @author King Lemming - * + * */ public class Fluid { @@ -45,7 +48,7 @@ public class Fluid /** * The light level emitted by this fluid. - * + * * Default value is 0, as most fluids do not actively emit light. */ protected int luminosity = 0; @@ -53,7 +56,7 @@ public class Fluid /** * Density of the fluid - completely arbitrary; negative density indicates that the fluid is * lighter than air. - * + * * Default value is approximately the real-life density of water in kg/m^3. */ protected int density = 1000; @@ -61,23 +64,23 @@ public class Fluid /** * Viscosity ("thickness") of the fluid - completely arbitrary; negative values are not * permissible. - * + * * Default value is approximately the real-life density of water in m/s^2 (x10^-3). */ protected int viscosity = 1000; /** * This indicates if the fluid is gaseous. - * + * * Useful for rendering the fluid in containers and the world. - * + * * Generally this is associated with negative density fluids. */ protected boolean isGaseous; /** * 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. */ protected int blockID = -1; @@ -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 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); + } } diff --git a/common/net/minecraftforge/fluids/FluidStack.java b/common/net/minecraftforge/fluids/FluidStack.java index 22ceed9ee..c41a9fccc 100644 --- a/common/net/minecraftforge/fluids/FluidStack.java +++ b/common/net/minecraftforge/fluids/FluidStack.java @@ -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; From e15c596e42330029849a2a46087b486432b00a46 Mon Sep 17 00:00:00 2001 From: tommy1019 Date: Sat, 27 Jul 2013 20:32:21 -0500 Subject: [PATCH 11/18] Fluid Rendering Fixes --- common/net/minecraftforge/fluids/BlockFluidBase.java | 2 +- common/net/minecraftforge/fluids/RenderBlockFluid.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/net/minecraftforge/fluids/BlockFluidBase.java b/common/net/minecraftforge/fluids/BlockFluidBase.java index a3bc54f76..c81e9e237 100644 --- a/common/net/minecraftforge/fluids/BlockFluidBase.java +++ b/common/net/minecraftforge/fluids/BlockFluidBase.java @@ -323,7 +323,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock public static double getFlowDirection(IBlockAccess world, int x, int y, int z) { Block block = Block.blocksList[world.getBlockId(x, y, z)]; - if (!(block instanceof BlockFluidBase)) + if (world.getBlockMaterial(x, y, z).isLiquid()) { return -1000.0; } diff --git a/common/net/minecraftforge/fluids/RenderBlockFluid.java b/common/net/minecraftforge/fluids/RenderBlockFluid.java index 6a065c554..bb2116db2 100644 --- a/common/net/minecraftforge/fluids/RenderBlockFluid.java +++ b/common/net/minecraftforge/fluids/RenderBlockFluid.java @@ -55,7 +55,7 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler { 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; } From 5c5cf3e7e783bfe24e6c88cc0c99647903009e0b Mon Sep 17 00:00:00 2001 From: cpw Date: Sun, 28 Jul 2013 19:15:00 +0200 Subject: [PATCH 12/18] Fix formatting error in PR --- .../minecraftforge/fluids/BlockFluidBase.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/common/net/minecraftforge/fluids/BlockFluidBase.java b/common/net/minecraftforge/fluids/BlockFluidBase.java index c81e9e237..dfcd7eb58 100644 --- a/common/net/minecraftforge/fluids/BlockFluidBase.java +++ b/common/net/minecraftforge/fluids/BlockFluidBase.java @@ -15,11 +15,11 @@ import net.minecraft.world.World; /** * 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. - * + * * @author King Lemming, OvermindDL1 - * + * */ public abstract class BlockFluidBase extends Block implements IFluidBlock { @@ -121,8 +121,8 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock { return false; } - - if (this.density > getDensity(world, x, y, z)) + + if (this.density > getDensity(world, x, y, z)) { return true; } @@ -164,7 +164,7 @@ 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; @@ -288,7 +288,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock int lightUpBase = lightUp & 255; int lightThisExt = lightThis >> 16 & 255; int lightUpExt = lightUp >> 16 & 255; - return (lightThisBase > lightUpBase ? lightThisBase : lightUpBase) | + return (lightThisBase > lightUpBase ? lightThisBase : lightUpBase) | ((lightThisExt > lightUpExt ? lightThisExt : lightUpExt) << 16); } @@ -397,7 +397,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock 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, 3) || isBlockSolid(world, x - 1, y, z, 4) || @@ -406,7 +406,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock isBlockSolid(world, x, y + 1, z + 1, 3) || isBlockSolid(world, x - 1, y + 1, z, 4) || isBlockSolid(world, x + 1, y + 1, z, 5); - + if (flag) { vec = vec.normalize().addVector(0.0D, -6.0D, 0.0D); From c3f62ed8bff9d1a5ea1e441a5325fd987d7aa545 Mon Sep 17 00:00:00 2001 From: cpw Date: Sun, 28 Jul 2013 19:25:51 +0200 Subject: [PATCH 13/18] Tweak setBlock in update tick - it should only send serverside updates for source blocks. Experimental attempt to fix worldgen issues for fluid blocks --- .../fluids/BlockFluidClassic.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/common/net/minecraftforge/fluids/BlockFluidClassic.java b/common/net/minecraftforge/fluids/BlockFluidClassic.java index 4defe7f6e..b5349ca6f 100644 --- a/common/net/minecraftforge/fluids/BlockFluidClassic.java +++ b/common/net/minecraftforge/fluids/BlockFluidClassic.java @@ -10,11 +10,11 @@ import net.minecraft.world.World; /** * 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. - * + * * @author King Lemming - * + * */ public class BlockFluidClassic extends BlockFluidBase { @@ -92,8 +92,8 @@ public class BlockFluidClassic extends BlockFluidBase { int y2 = y - densityDir; - if (world.getBlockId(x, y2, z ) == blockID || - world.getBlockId(x - 1, 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, 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 @@ -226,7 +227,7 @@ public class BlockFluidClassic extends BlockFluidBase int cost = 1000; for (int adjSide = 0; adjSide < 4; adjSide++) { - if ((adjSide == 0 && side == 1) || + if ((adjSide == 0 && side == 1) || (adjSide == 1 && side == 0) || (adjSide == 2 && side == 3) || (adjSide == 3 && side == 2)) @@ -302,7 +303,7 @@ public class BlockFluidClassic extends BlockFluidBase { return false; } - + if (this.density > getDensity(world, x, y, z)) { return true; From 89d9fb3556ba93f08ac9fb9cbad467625c0d5d3d Mon Sep 17 00:00:00 2001 From: cpw Date: Sun, 28 Jul 2013 22:40:13 +0200 Subject: [PATCH 14/18] Updated FML: MinecraftForge/FML@57befa89bbbf2bc2fcc4a97b78e07b3f9e23ef9d Fix keybindings being derped MinecraftForge/FML@1d84e8063e9d0dc73928dba006e6001201285cad Temporarily add a version of 'reobfuscate.py' that will resolve complex reobfuscation graph issues with specialsource. Copy it over 'reobfuscate.py' in the mcp runtime dir. Hopefully will have an MCP/specialsource fix in the coming days. --- fml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fml b/fml index 10b16d32d..1d84e8063 160000 --- a/fml +++ b/fml @@ -1 +1 @@ -Subproject commit 10b16d32da4b7c32b15e69cf1c636505ebbe2540 +Subproject commit 1d84e8063e9d0dc73928dba006e6001201285cad From 7b9971b20f6e085a95e633ece4a5c3b1b3b26f7f Mon Sep 17 00:00:00 2001 From: iChun Date: Wed, 31 Jul 2013 08:03:10 +0800 Subject: [PATCH 15/18] Fix RenderLivingEvent.Pre/Post not being fired by most Renders. --- .../entity/RendererLivingEntity.java.patch | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch index 4a92efc5f..9df5e61cf 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch @@ -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 @@ } } } @@ -43,12 +59,3 @@ } protected boolean func_110813_b(EntityLivingBase par1EntityLivingBase) -@@ -570,6 +578,8 @@ - */ - public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) - { -+ if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre((EntityLivingBase)par1Entity, this))) return; - this.func_130000_a((EntityLivingBase)par1Entity, par2, par4, par6, par8, par9); -+ MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post((EntityLivingBase)par1Entity, this)); - } -} From bf8f5aa306036b8a1d9411ecff3b6beea9c4547e Mon Sep 17 00:00:00 2001 From: Matthew Warren Date: Wed, 31 Jul 2013 22:15:42 -0500 Subject: [PATCH 16/18] added temperature to fluids it could be useful for blocks that are affected by temperature --- .../minecraftforge/fluids/BlockFluidBase.java | 18 ++++++++++++++++ common/net/minecraftforge/fluids/Fluid.java | 21 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/common/net/minecraftforge/fluids/BlockFluidBase.java b/common/net/minecraftforge/fluids/BlockFluidBase.java index 5aea68e42..fbb30d073 100644 --- a/common/net/minecraftforge/fluids/BlockFluidBase.java +++ b/common/net/minecraftforge/fluids/BlockFluidBase.java @@ -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; @@ -303,6 +311,16 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock } 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) { diff --git a/common/net/minecraftforge/fluids/Fluid.java b/common/net/minecraftforge/fluids/Fluid.java index b7c6f9147..d9dbbbf81 100644 --- a/common/net/minecraftforge/fluids/Fluid.java +++ b/common/net/minecraftforge/fluids/Fluid.java @@ -58,6 +58,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 +140,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 +214,11 @@ public class Fluid return this.density; } + public final int getTemperature() + { + return this.temperature; + } + public final int getViscosity() { return this.viscosity; @@ -252,6 +271,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,6 +279,7 @@ 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(); } From 90e0eaf5f5af099893f2ec1520e0e6442163356f Mon Sep 17 00:00:00 2001 From: Heldplayer Date: Sat, 3 Aug 2013 23:20:34 +0200 Subject: [PATCH 17/18] Fix render colour on bottom of fluids --- common/net/minecraftforge/fluids/RenderBlockFluid.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/net/minecraftforge/fluids/RenderBlockFluid.java b/common/net/minecraftforge/fluids/RenderBlockFluid.java index bb2116db2..7386f52ba 100644 --- a/common/net/minecraftforge/fluids/RenderBlockFluid.java +++ b/common/net/minecraftforge/fluids/RenderBlockFluid.java @@ -204,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)); } } From 647f6fdf346384fd66c9773f7c971b59dd533433 Mon Sep 17 00:00:00 2001 From: Heldplayer Date: Sat, 3 Aug 2013 23:42:38 +0200 Subject: [PATCH 18/18] Fix small derp --- common/net/minecraftforge/fluids/BlockFluidBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/net/minecraftforge/fluids/BlockFluidBase.java b/common/net/minecraftforge/fluids/BlockFluidBase.java index 7961b0a11..826ec6c07 100644 --- a/common/net/minecraftforge/fluids/BlockFluidBase.java +++ b/common/net/minecraftforge/fluids/BlockFluidBase.java @@ -341,7 +341,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock 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()) + if (!world.getBlockMaterial(x, y, z).isLiquid()) { return -1000.0; }