mojira.dev
MC-9565

Fences and Cobblestone Walls connect to Fence Gates, which are facing the other direction

What I expected to happen was:

Fences don't connect with Fence Gates facing in the other direction

What actually happened was:

Fences do connect with Fence Gates facing in the other direction

Steps to Reproduce:

1. Place two Fences with a one block gap between
2. Place a Fence gate, that it looks like a cross with the two fences

Linked issues

Attachments

Comments 19

Please do not mark unreleased versions (anything starting with "Future Version") as affected. You don't have access to them yet.

Confirmed for 1.7.5 and 14w11b

Confirmed for 14w18b and 14w19a

Affects version 14w28a as well.

Using code from MCP 9.08 for MC1.7.10 I've been able to correct this in my personal mod with the following changes:

blocks/BlockFence.java

public void addCollisionBoxesToList(World par1, int par2, int par3, int par4, AxisAlignedBB par5, List par6, Entity par7)
    {
        boolean var8 = this.func_149826_e(par1, par2, par3, par4 - 1) && (!(par1.getBlock(par2, par3, par4 - 1) instanceof BlockFenceGate) || (par1.getBlockMetadata(par2, par3, par4 - 1) & 1) == 1);
        boolean var9 = this.func_149826_e(par1, par2, par3, par4 + 1) && (!(par1.getBlock(par2, par3, par4 + 1) instanceof BlockFenceGate) || (par1.getBlockMetadata(par2, par3, par4 + 1) & 1) == 1);
        boolean var10 = this.func_149826_e(par1, par2 - 1, par3, par4) && (!(par1.getBlock(par2 - 1, par3, par4) instanceof BlockFenceGate) || (par1.getBlockMetadata(par2 - 1, par3, par4) & 1) == 0);
        boolean var11 = this.func_149826_e(par1, par2 + 1, par3, par4) && (!(par1.getBlock(par2 + 1, par3, par4) instanceof BlockFenceGate) || (par1.getBlockMetadata(par2 + 1, par3, par4) & 1) == 0);
.
.
.

    public void setBlockBoundsBasedOnState(IBlockAccess par1, int par2, int par3, int par4)
    {
        boolean var5 = this.func_149826_e(par1, par2, par3, par4 - 1) && (!(par1.getBlock(par2, par3, par4 - 1) instanceof BlockFenceGate) || (par1.getBlockMetadata(par2, par3, par4 - 1) & 1) == 1);
        boolean var6 = this.func_149826_e(par1, par2, par3, par4 + 1) && (!(par1.getBlock(par2, par3, par4 + 1) instanceof BlockFenceGate) || (par1.getBlockMetadata(par2, par3, par4 + 1) & 1) == 1);
        boolean var7 = this.func_149826_e(par1, par2 - 1, par3, par4) && (!(par1.getBlock(par2 - 1, par3, par4) instanceof BlockFenceGate) || (par1.getBlockMetadata(par2 - 1, par3, par4) & 1) == 0);
        boolean var8 = this.func_149826_e(par1, par2 + 1, par3, par4) && (!(par1.getBlock(par2 + 1, par3, par4) instanceof BlockFenceGate) || (par1.getBlockMetadata(par2 + 1, par3, par4) & 1) == 0);
.
.
.
   public boolean func_149826_e(IBlockAccess par1, int par2, int par3, int par4)
    {
        Block var5 = par1.getBlock(par2, par3, par4);
        
        boolean ret = (var5 == this);
        if (!ret)
        {
	        if (var5 instanceof BlockFence)
	        {
	        	ret = this.blockMaterial == var5.blockMaterial;
	        }
	        else if (var5 instanceof BlockFenceGate)
	        {
	        	ret = true;
	        }
	        else if (var5.blockMaterial.isOpaque() && var5.renderAsNormalBlock())
	        {
	        	ret = var5.blockMaterial != Material.field_151572_C; //don't connect to melons or pumpkins
	        	ret = ret && var5 != Blocks.hay_block;
	        }
        }
        else //always connect to self
        {
        	ret = true;
        }
        
        return ret;
    }

client/renderer/RenderBlocks.java

public boolean renderBlockFence(BlockFence par1, int par2, int par3, int par4)
    {
.
.
.
				Block nearBlock = null;

        if (par1.func_149826_e(this.blockAccess, par2 - 1, par3, par4) || par1.func_149826_e(this.blockAccess, par2 + 1, par3, par4))
        {
            if (!(this.blockAccess.getBlock(par2 - 1, par3, par4) instanceof BlockFenceGate) || (this.blockAccess.getBlockMetadata(par2 - 1, par3, par4) & 1) == 0)
            {
            	var8 = true;
            }
            else if (!(this.blockAccess.getBlock(par2 + 1, par3, par4) instanceof BlockFenceGate) || (this.blockAccess.getBlockMetadata(par2 + 1, par3, par4) & 1) == 0)
            {
            	var8 = true;
            }
        }

        if (par1.func_149826_e(this.blockAccess, par2, par3, par4 - 1) || par1.func_149826_e(this.blockAccess, par2, par3, par4 + 1))
        {
            if (!(this.blockAccess.getBlock(par2, par3, par4 - 1) instanceof BlockFenceGate) || (this.blockAccess.getBlockMetadata(par2, par3, par4 - 1) & 1) == 1)
            {
            	var9 = true;
            }
            else if (!(this.blockAccess.getBlock(par2, par3, par4 + 1) instanceof BlockFenceGate) || (this.blockAccess.getBlockMetadata(par2, par3, par4 + 1) & 1) == 1)
            {
            	var9 = true;
            }
				}

        boolean var10 = par1.func_149826_e(this.blockAccess, par2 - 1, par3, par4) && (!(this.blockAccess.getBlock(par2 - 1, par3, par4) instanceof BlockFenceGate) || (this.blockAccess.getBlockMetadata(par2 - 1, par3, par4) & 1) == 0);
        boolean var11 = par1.func_149826_e(this.blockAccess, par2 + 1, par3, par4) && (!(this.blockAccess.getBlock(par2 + 1, par3, par4) instanceof BlockFenceGate) || (this.blockAccess.getBlockMetadata(par2 + 1, par3, par4) & 1) == 0); 
        boolean var12 = par1.func_149826_e(this.blockAccess, par2, par3, par4 - 1) && (!(this.blockAccess.getBlock(par2, par3, par4 - 1) instanceof BlockFenceGate) || (this.blockAccess.getBlockMetadata(par2, par3, par4 - 1) & 1) == 1);
        boolean var13 = par1.func_149826_e(this.blockAccess, par2, par3, par4 + 1) && (!(this.blockAccess.getBlock(par2, par3, par4 + 1) instanceof BlockFenceGate) || (this.blockAccess.getBlockMetadata(par2, par3, par4 + 1) & 1) == 1);
.
.
.

Sorry to dump this on you - I hope your open to coding changes with actual code examples. I just made a suggestion in reddit/minecraftSuggestions about this very issue.

This same code can be used to fix BlockWall as well.

Note that changes to BlockFence.java/func_149826_e contain some alterations to make fences not connect to melons or hay blocks; exclude that at your preference.

9 more comments

Confirmed for 15w43c

@@unknown: It's sufficient to add the affected version, you don't need to add a "Confirmed for ..." comment.

Still present in 1.9-pre1; it occurs with all fence/fence gate types, including nether brick fence and cobblestone wall.

I know the code has probably changed a bit since May of 2014, but maybe that sample commented from then is still a possible solution for this near 4 year old problem?

Still happens in 17w15a. This problem drives me insane with OCD. Please fix it.

bl4ckscor3

migrated

Confirmed

cobblestone_wall, fence, fence_gate, rendering

Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w05b, Snapshot 13w06a, Minecraft 1.5.1, ..., Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w13b, Minecraft 17w14a, Minecraft 17w15a

Minecraft 17w16a

Retrieved