From ebd22c3abd953705d033dd0649203fd88636d2ab Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 10 Jun 2013 16:57:34 -0400 Subject: [PATCH] Make glass panes and iron fences connect to block sides based on solidity. This does change IBlockAccess, so anything with a custom IBlockAccess may need to implement the new method. --- .../net/minecraft/block/BlockPane.java.patch | 51 +++++++++++++++++++ .../client/renderer/RenderBlocks.java.patch | 15 ++++++ .../net/minecraft/world/ChunkCache.java.patch | 37 ++++++++++++-- .../minecraft/world/IBlockAccess.java.patch | 27 ++++++++++ .../net/minecraft/world/World.java.patch | 3 +- 5 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 patches/minecraft/net/minecraft/block/BlockPane.java.patch create mode 100644 patches/minecraft/net/minecraft/world/IBlockAccess.java.patch diff --git a/patches/minecraft/net/minecraft/block/BlockPane.java.patch b/patches/minecraft/net/minecraft/block/BlockPane.java.patch new file mode 100644 index 000000000..5753ac2be --- /dev/null +++ b/patches/minecraft/net/minecraft/block/BlockPane.java.patch @@ -0,0 +1,51 @@ +--- ../src_base/minecraft/net/minecraft/block/BlockPane.java ++++ ../src_work/minecraft/net/minecraft/block/BlockPane.java +@@ -13,6 +13,7 @@ + import net.minecraft.util.Icon; + import net.minecraft.world.IBlockAccess; + import net.minecraft.world.World; ++import net.minecraftforge.common.ForgeDirection; + + public class BlockPane extends Block + { +@@ -90,10 +91,10 @@ + */ + public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) + { +- boolean flag = this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 - 1)); +- boolean flag1 = this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 + 1)); +- boolean flag2 = this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 - 1, par3, par4)); +- boolean flag3 = this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 + 1, par3, par4)); ++ boolean flag = this.canPaneConnectTo(par1World,par2, par3, par4,ForgeDirection.NORTH); ++ boolean flag1 = this.canPaneConnectTo(par1World,par2, par3, par4,ForgeDirection.SOUTH); ++ boolean flag2 = this.canPaneConnectTo(par1World,par2, par3, par4,ForgeDirection.WEST); ++ boolean flag3 = this.canPaneConnectTo(par1World,par2, par3, par4,ForgeDirection.EAST); + + if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) + { +@@ -151,10 +152,10 @@ + float f1 = 0.5625F; + float f2 = 0.4375F; + float f3 = 0.5625F; +- boolean flag = this.canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2, par3, par4 - 1)); +- boolean flag1 = this.canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2, par3, par4 + 1)); +- boolean flag2 = this.canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2 - 1, par3, par4)); +- boolean flag3 = this.canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2 + 1, par3, par4)); ++ boolean flag = this.canPaneConnectTo(par1IBlockAccess,par2, par3, par4,ForgeDirection.NORTH); ++ boolean flag1 = this.canPaneConnectTo(par1IBlockAccess,par2, par3, par4,ForgeDirection.SOUTH); ++ boolean flag2 = this.canPaneConnectTo(par1IBlockAccess,par2, par3, par4,ForgeDirection.WEST); ++ boolean flag3 = this.canPaneConnectTo(par1IBlockAccess,par2, par3, par4,ForgeDirection.EAST); + + if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) + { +@@ -240,4 +241,10 @@ + this.blockIcon = par1IconRegister.registerIcon(this.field_94402_c); + this.theIcon = par1IconRegister.registerIcon(this.sideTextureIndex); + } ++ ++ // FORGE START ++ public boolean canPaneConnectTo(IBlockAccess access, int x, int y, int z, ForgeDirection dir) ++ { ++ return canThisPaneConnectToThisBlockID(access.getBlockId(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ)) || access.isBlockSolidOnSide(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, dir.getOpposite(), false); ++ } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/RenderBlocks.java.patch b/patches/minecraft/net/minecraft/client/renderer/RenderBlocks.java.patch index 282a42f69..d8f2dc673 100644 --- a/patches/minecraft/net/minecraft/client/renderer/RenderBlocks.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/RenderBlocks.java.patch @@ -91,3 +91,18 @@ { d5 = (double)par2 + 0.5D + 0.5D; d6 = (double)par2 + 0.5D - 0.5D; +@@ -3050,10 +3053,10 @@ + double d17 = (double)par2 + 0.5D + 0.0625D; + double d18 = (double)par4 + 0.5D - 0.0625D; + double d19 = (double)par4 + 0.5D + 0.0625D; +- boolean flag = par1BlockPane.canThisPaneConnectToThisBlockID(this.blockAccess.getBlockId(par2, par3, par4 - 1)); +- boolean flag1 = par1BlockPane.canThisPaneConnectToThisBlockID(this.blockAccess.getBlockId(par2, par3, par4 + 1)); +- boolean flag2 = par1BlockPane.canThisPaneConnectToThisBlockID(this.blockAccess.getBlockId(par2 - 1, par3, par4)); +- boolean flag3 = par1BlockPane.canThisPaneConnectToThisBlockID(this.blockAccess.getBlockId(par2 + 1, par3, par4)); ++ boolean flag = par1BlockPane.canPaneConnectTo(this.blockAccess,par2, par3, par4, NORTH); ++ boolean flag1 = par1BlockPane.canPaneConnectTo(this.blockAccess,par2, par3, par4, SOUTH); ++ boolean flag2 = par1BlockPane.canPaneConnectTo(this.blockAccess,par2, par3, par4, WEST); ++ boolean flag3 = par1BlockPane.canPaneConnectTo(this.blockAccess,par2, par3, par4, EAST); + boolean flag4 = par1BlockPane.shouldSideBeRendered(this.blockAccess, par2, par3 + 1, par4, 1); + boolean flag5 = par1BlockPane.shouldSideBeRendered(this.blockAccess, par2, par3 - 1, par4, 0); + diff --git a/patches/minecraft/net/minecraft/world/ChunkCache.java.patch b/patches/minecraft/net/minecraft/world/ChunkCache.java.patch index 964c526a6..b88c07db1 100644 --- a/patches/minecraft/net/minecraft/world/ChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/world/ChunkCache.java.patch @@ -1,6 +1,14 @@ --- ../src_base/minecraft/net/minecraft/world/ChunkCache.java +++ ../src_work/minecraft/net/minecraft/world/ChunkCache.java -@@ -108,7 +108,15 @@ +@@ -8,6 +8,7 @@ + import net.minecraft.util.Vec3Pool; + import net.minecraft.world.biome.BiomeGenBase; + import net.minecraft.world.chunk.Chunk; ++import net.minecraftforge.common.ForgeDirection; + + public class ChunkCache implements IBlockAccess + { +@@ -108,7 +109,15 @@ { int l = (par1 >> 4) - this.chunkX; int i1 = (par3 >> 4) - this.chunkZ; @@ -17,7 +25,7 @@ } @SideOnly(Side.CLIENT) -@@ -159,7 +167,12 @@ +@@ -159,7 +168,12 @@ { int l = (par1 >> 4) - this.chunkX; int i1 = (par3 >> 4) - this.chunkZ; @@ -31,7 +39,7 @@ } } -@@ -306,8 +319,7 @@ +@@ -306,8 +320,7 @@ */ public boolean doesBlockHaveSolidTopSurface(int par1, int par2, int par3) { @@ -41,3 +49,26 @@ } /** +@@ -449,4 +462,22 @@ + int i1 = this.getBlockId(par1, par2, par3); + return i1 == 0 ? 0 : Block.blocksList[i1].isProvidingStrongPower(this, par1, par2, par3, par4); + } ++ ++ public boolean isBlockSolidOnSide(int x, int y, int z, ForgeDirection side, boolean _default) ++ { ++ if (x < -30000000 || z < -30000000 || x >= 30000000 || z >= 30000000) ++ { ++ return _default; ++ } ++ ++ int blockId = getBlockId(x, y, z); ++ Block block = Block.blocksList[blockId]; ++ ++ if (block != null) ++ { ++ return block.isBlockSolidOnSide(this.worldObj, x, y, z, side); ++ } ++ ++ return false; ++ } + } diff --git a/patches/minecraft/net/minecraft/world/IBlockAccess.java.patch b/patches/minecraft/net/minecraft/world/IBlockAccess.java.patch new file mode 100644 index 000000000..eddd893e4 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/IBlockAccess.java.patch @@ -0,0 +1,27 @@ +--- ../src_base/minecraft/net/minecraft/world/IBlockAccess.java ++++ ../src_work/minecraft/net/minecraft/world/IBlockAccess.java +@@ -6,6 +6,7 @@ + import net.minecraft.tileentity.TileEntity; + import net.minecraft.util.Vec3Pool; + import net.minecraft.world.biome.BiomeGenBase; ++import net.minecraftforge.common.ForgeDirection; + + public interface IBlockAccess + { +@@ -103,4 +104,16 @@ + * Is this block powering in the specified direction Args: x, y, z, direction + */ + int isBlockProvidingPowerTo(int i, int j, int k, int l); ++ ++ /** ++ * FORGE: isBlockSolidOnSide, pulled up from {@link World} ++ * ++ * @param x X coord ++ * @param y Y coord ++ * @param z Z coord ++ * @param side Side ++ * @param _default default return value ++ * @return if the block is solid on the side ++ */ ++ boolean isBlockSolidOnSide(int x, int y, int z, ForgeDirection side, boolean _default); + } diff --git a/patches/minecraft/net/minecraft/world/World.java.patch b/patches/minecraft/net/minecraft/world/World.java.patch index 6174ae6a0..cb8dae659 100644 --- a/patches/minecraft/net/minecraft/world/World.java.patch +++ b/patches/minecraft/net/minecraft/world/World.java.patch @@ -812,7 +812,7 @@ } /** -@@ -4321,4 +4491,114 @@ +@@ -4321,4 +4491,115 @@ { return this.worldLogAgent; } @@ -856,6 +856,7 @@ + * @param _default The defult to return if the block doesn't exist. + * @return True if the side is solid + */ ++ @Override + public boolean isBlockSolidOnSide(int x, int y, int z, ForgeDirection side, boolean _default) + { + if (x < -30000000 || z < -30000000 || x >= 30000000 || z >= 30000000)