mojira.dev
MC-1935

Fence gate next to a wall has an incorrect hitbox

When a fence gate is between 2 cobblestone walls, the fence gate has incorrect hitboxes.

Related issues

Attachments

Comments

migrated
[media][media][media][media][media]
migrated

I think that's intented as you could jump over those gates if they would lower the collision box.

migrated

@Meta
The selection box and collision box are different things - look at fences or stone walls.

migrated

Intended.
They want to control the fence gate's height without changing the selection box (As that would require a new metadata value rather than an NBT)

The fence model gets lowered to match the cobblestone wall's height, but they don't want to change the selection box, resulting in the small gap between the top of the gate and the top of the collision box.

bugi74

The rendering code adjusts the rendered height location of the gate depending on what it has on its sides. I see no reason why the code which decides the selection box could not do the same just as well, it is just a bit more coding (or, as customary in Minecraft code, copying). No changes to metadata is needed for that.

bugi74

And another bites the dust.

Current code

BlockFenceGate

public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
        int var5 = getDirection(blockAccess.getBlockMetadata(x, y, z));

        if (var5 != 2 && var5 != 0) {
            this.setBlockBounds(0.375F, 0.0F, 0.0F, 0.625F, 1.0F, 1.0F);
        } else {
            this.setBlockBounds(0.0F, 0.0F, 0.375F, 1.0F, 1.0F, 0.625F);
        }
    }

Fixed

BlockFenceGate

public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
        int var5 = getDirection(blockAccess.getBlockMetadata(x, y, z));

        if (var5 != 2 && var5 != 0) {
            if (blockAccess.getBlockId(x, y, z - 1) == Block.cobblestoneWall.blockID
                    && blockAccess.getBlockId(x, y, z + 1) == Block.cobblestoneWall.blockID)
                this.setBlockBounds(0.375F, 0.0F, 0.0F, 0.625F, 0.8125F, 1.0F); // Lower the top
            else 
                this.setBlockBounds(0.375F, 0.0F, 0.0F, 0.625F, 1.0F, 1.0F);
        } else {
            if (blockAccess.getBlockId(x - 1, y, z) == Block.cobblestoneWall.blockID
                    && blockAccess.getBlockId(x + 1, y, z) == Block.cobblestoneWall.blockID)
                this.setBlockBounds(0.0F, 0.0F, 0.375F, 1.0F, 0.8125F, 0.625F); // Lower the top
            else
                this.setBlockBounds(0.0F, 0.0F, 0.375F, 1.0F, 1.0F, 0.625F);
        }
    }

Tested on 1.4.7 very briefly. May have some unexpected side results, but at least adding and removing worked as expected, and the selection box got adjusted as wished. I attached a screenshot showing the result.

However, while testing I noticed that at least in my opinion, the logical operation between the two cobblestone walls should be "or" instead of "and". It looks quite stupid as it is now, as the fencegate will be higher than the lower side block. (As also seen in the screenshot). If changed, there are two places to do the same change. This method here, and also in the RenderBlocks-class.

bugi74

Affects 13w09b.

ileon

:/

bugi74

A 20 seconds test in creative mode confirms this exists in 1.6.2 (as expected).

migrated

Affects 1.6.4.

migrated

Confirmed for 08a

migrated

Confirmed for 14w21b.

marcono1234

Confirmed for 14w25b

rydian
migrated

Confirmed for 15w44b.

rydian

Still there in 15w47a.

ileon

Erik Broes

Confirmed

fence_gate, hitbox

Minecraft 1.4.3, Minecraft 1.4.5, Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w04a, ..., Minecraft 1.8.1-pre2, Minecraft 15w44b, Minecraft 15w45a, Minecraft 15w46a, Minecraft 15w47a

Minecraft 16w07a

Retrieved