What I expected to happen was...:
The blocks should have connected while being pushed.
What actually happened was...:
When they were being pushed, they connected to solid blocks but not to each other.
Steps to Reproduce:
1. Push multiple bars, panes, fences or walls with a piston.
2. Put solid blocks next to them.
3. They will connect to the solid blocks but not to each other while they are pushed.
Related issues
is duplicated by
relates to
Attachments
Comments


Where is the bug ? That's at most an annoyance.
Confirmed in 13w04a.

(Perhaps a moderator would adjust the summary to remove the pistons part, as that seems to be irrelevant for this issue.)
The behavior seems to have nothing to do with pistons, but with the overall visual rendering of all the "slim" shaped blocks (fences, panes, bars, walls, fencegates). See the screenshot 'borked_fences.png' (which is with 1.4.7 and no pistons needed).
I made the necessary fixes to connect each of them with each other type, and now it works also when they are both in static case and when been moved by pistons. That is, they automatically connect or "switch direction" as needed after moved. In fact, it is impossible to move them so that they would keep their original orientation (except fencegate), as there is no direction info (except for that fencegate). See the screenshot 'fixed_fences_pistons.png' for the fixed situation.
The needed code changes are quite small and straight forward... coming right up...
Fixes
BlockPane
public final boolean canThisPaneConnectToThisBlockID(int par1) {
return Block.opaqueCubeLookup[par1] || par1 == Block.thinGlass.blockID || par1 == Block.glass.blockID // MINOR CHANGE
|| par1 == Block.fence.blockID || par1 == Block.fenceIron.blockID // ADDED
|| par1 == Block.netherFence.blockID || par1 == Block.cobblestoneWall.blockID // ADDED
|| par1 == Block.fenceGate.blockID; // ADDED
}
BlockFence
public boolean canConnectFenceTo(IBlockAccess blockAccess, int par2, int par3, int par4) {
int bid = blockAccess.getBlockId(par2, par3, par4);
if (bid != Block.fence.blockID && bid != Block.fenceGate.blockID // MINOR CHANGE
&& bid != Block.fenceIron.blockID && bid != Block.netherFence.blockID // ADDED
&& bid != Block.cobblestoneWall.blockID && bid != Block.thinGlass.blockID) { // ADDED
...
BlockWall
public boolean canConnectWallTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
int var5 = par1IBlockAccess.getBlockId(par2, par3, par4);
if (var5 != this.blockID && var5 != Block.fenceGate.blockID
&& var5 != Block.fenceIron.blockID && var5 != Block.netherFence.blockID // ADDED
&& var5 != Block.fence.blockID && var5 != Block.thinGlass.blockID) { // ADDED
...
The minor changes are needed so that iron bars connect to glass panes, and for nether fences to connect with normal fences. Also note that fence gate orientation is not checked, but it wasn't checked earlier either (for those blocks with which there was connection), but that would be another bug/"feature".
Fixes tested on 1.4.7
I'd change all these block types to use a single method, along the lines of "isSlimFenceStyleBlockWithAutoOrientation()" and adjust the fixes correspondingly. That would make the code cleaner, and would be more "future proof". (This issue is a good example what happens when that guideline is not followed.) The above fixes are in the current design/style just to keep the fixes simple and easier to understand what the change does.
Note that some of them do not connect visually well (especially walls and fences), but then again, the current way of not connecting at all looks even worse.


Affects 13w09c.

Fixed also fences/walls with backsides of stairs. Especially nice looking combinations with equal materials. Code fixes coming...

These fixes are in addition to the fixes above. Also, it would be best to fix all of this, MC-9176 and MC-8345 at the same time; the code changes are pretty much shared/similar. Also, once all fixes are imported, might be a good idea to take a look at the duplication and functionality over all, and give some much needed object-oriented love to the related code. Would reduce the amount of code, make coding new similar features a blink (instead of a pain of bugs), and thus reduce "maintenance costs".
Fixes
BlockFence
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
// boolean north = this.canConnectFenceTo(world, x, y, z - 1);
// boolean south = this.canConnectFenceTo(world, x, y, z + 1);
// boolean west = this.canConnectFenceTo(world, x - 1, y, z);
// boolean east = this.canConnectFenceTo(world, x + 1, y, z);
boolean north = this.canFenceAtConnectToDir(world, x, y, z, 3);
boolean south = this.canFenceAtConnectToDir(world, x, y, z, 2);
boolean west = this.canFenceAtConnectToDir(world, x, y, z, 5);
boolean east = this.canFenceAtConnectToDir(world, x, y, z, 4);
...
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
// boolean north = this.canConnectFenceTo(blockAccess, x, y, z - 1);
// boolean south = this.canConnectFenceTo(blockAccess, x, y, z + 1);
// boolean west = this.canConnectFenceTo(blockAccess, x - 1, y, z);
// boolean east = this.canConnectFenceTo(blockAccess, x + 1, y, z);
boolean north = this.canFenceAtConnectToDir(blockAccess, x, y, z, 3);
boolean south = this.canFenceAtConnectToDir(blockAccess, x, y, z, 2);
boolean west = this.canFenceAtConnectToDir(blockAccess, x, y, z, 5);
boolean east = this.canFenceAtConnectToDir(blockAccess, x, y, z, 4);
...
/**
* @param dir 1 = bottom, 2 = z+1, 3 = z-1, 4 = x+1, 5 = x-1, top = 0 or anything else
*/
public boolean canFenceAtConnectToDir(IBlockAccess access, int x, int y, int z, int dir) {
switch (dir) {
case 2: { z++; break; }
case 3: { z--; break; }
case 4: { x++; break; }
case 5: { x--; break; }
default: return false;
}
if (this.canConnectFenceTo(access, x, y, z)) return true; // Old check
int blockId = access.getBlockId(x, y, z);
// Checking for full solid surface to touch..
Block block = Block.blocksList[blockId];
if (block == null)
return false;
return block.hasSolidFullSurfaceAt(access, x, y, z, dir);
}
BlockWall
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
// boolean north = this.canConnectWallTo(blockAccess, x, y, z - 1);
// boolean south = this.canConnectWallTo(blockAccess, x, y, z + 1);
// boolean west = this.canConnectWallTo(blockAccess, x - 1, y, z);
// boolean east = this.canConnectWallTo(blockAccess, x + 1, y, z);
boolean north = this.canWallAtConnectToDir(blockAccess, x, y, z, 3);
boolean south = this.canWallAtConnectToDir(blockAccess, x, y, z, 2);
boolean west = this.canWallAtConnectToDir(blockAccess, x, y, z, 5);
boolean east = this.canWallAtConnectToDir(blockAccess, x, y, z, 4);
...
public boolean canWallAtConnectToDir(IBlockAccess access, int x, int y, int z, int dir) {
switch (dir) {
case 2: { z++; break; }
case 3: { z--; break; }
case 4: { x++; break; }
case 5: { x--; break; }
default: return false;
}
if (this.canConnectWallTo(access, x, y, z)) return true; // Old check
int blockId = access.getBlockId(x, y, z);
// Checking for full solid surface to touch..
Block block = Block.blocksList[blockId];
if (block == null)
return false;
return block.hasSolidFullSurfaceAt(access, x, y, z, dir);
}
(Below, note the swapped order; halves the number of calls to the method.)
RenderBlocks
public boolean renderBlockFence(BlockFence blockFence, int x, int y, int z) {
...
// if (blockFence.canConnectFenceTo(this.blockAccess, x - 1, y, z) || blockFence.canConnectFenceTo(this.blockAccess, x + 1, y, z)) {
// var8 = true;
// }
//
// if (blockFence.canConnectFenceTo(this.blockAccess, x, y, z - 1) || blockFence.canConnectFenceTo(this.blockAccess, x, y, z + 1)) {
// var9 = true;
// }
//
// boolean west = blockFence.canConnectFenceTo(this.blockAccess, x - 1, y, z);
// boolean east = blockFence.canConnectFenceTo(this.blockAccess, x + 1, y, z);
// boolean north = blockFence.canConnectFenceTo(this.blockAccess, x, y, z - 1);
// boolean south = blockFence.canConnectFenceTo(this.blockAccess, x, y, z + 1);
boolean west = blockFence.canFenceAtConnectToDir(blockAccess, x, y, z, 5);
boolean east = blockFence.canFenceAtConnectToDir(blockAccess, x, y, z, 4);
boolean north = blockFence.canFenceAtConnectToDir(blockAccess, x, y, z, 3);
boolean south = blockFence.canFenceAtConnectToDir(blockAccess, x, y, z, 2);
if (west || east) {
var8 = true;
}
if (north || south) {
var9 = true;
}
...
public boolean renderBlockWall(BlockWall blockWall, int x, int y, int z) {
// boolean west = blockWall.canConnectWallTo(this.blockAccess, x - 1, y, z);
// boolean east = blockWall.canConnectWallTo(this.blockAccess, x + 1, y, z);
// boolean north = blockWall.canConnectWallTo(this.blockAccess, x, y, z - 1);
// boolean south = blockWall.canConnectWallTo(this.blockAccess, x, y, z + 1);
boolean west = blockWall.canWallAtConnectToDir(blockAccess, x, y, z, 5);
boolean east = blockWall.canWallAtConnectToDir(blockAccess, x, y, z, 4);
boolean north = blockWall.canWallAtConnectToDir(blockAccess, x, y, z, 3);
boolean south = blockWall.canWallAtConnectToDir(blockAccess, x, y, z, 2);
...
Changes were tested against 1.4.7; the example screenshot 'fixed-backofstairs-fences.png' is from there (along with fixes applies to the two already mentioned other issues).
Attached images of Glass panes and Iron bars with cobblestone walls. Likely applies to fences too.

Is this still a concern in the current Minecraft version 1.6.4 / Launcher version 1.2.5 ? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Still in 1.6.4.

Iron Bars and Glass Panes are connecting in 1.7.
Confirmed for 1.7.5 and 14w10c
Confirmed for 14w11b
Confirmed for 14w17a

I think this bug can be resolved as of 14w32d
Walls do not connect to fences (WAI)
Nether fences do not connect to fences (WAI)
Panes and bars do connect (Tested in 14w32d)
https://twitter.com/_grum/status/497382456111431680
https://twitter.com/_grum/status/497489801386684416
https://twitter.com/_grum/status/497500228048936960

Since several different bugs were made duplicates of this issue, but only one part of them was now fixed and/or made WAI, it might be proper to detach and reopen the other ones. For example, have the bars/panes or connecting to back of stairs been fixed or declared WAI (latter would be just stupid, imho)?
Or maybe better to actually detach the MC-27428 and MC-34985 from this and declare them as WAI, leave this one open.
Edit: would also be nice if Mojang would stop using Twitter as the official bug management system. Apparently reporting issues there works, and Mojang likes to state the results there, too, instead of this JIRA.

That still leaves (partially overlapping) issues:
MC-10613 Fences doesn't connect with stairs
MC-11527 Iron Bars & Glass Panes with Cobblestone Walls
MC-20733 Glass Panes do not connect to iron bars
MC-35272 Iron bars/glass panes sticky piston graphical glitch
MC-35665 Glass panes don't join up correctly with ice blocks
MC-41886 Piston Glass Bug
MC-49644 Glass panes not connecting to ice
I think MC-36454 Fences Not Attaching is also WAI and should now be detached.
That is why I thought it might be better leave this issue open, as it is mostly about other issues than the ones that have now been solved. The way the issues are now marked, the fence vs. wall connection resolved as WAI and marked (previously) to this issue translates to all the other issues marked as WAI, too (via duplication resolution) 😛
It will be completely fixed in 1.9 according to Searge
confirmed for 1.8