Anvil/Chest Manipulation: Difference between revisions

From Minecraft Parkour Wiki
Content added Content deleted
(added explanation)
mNo edit summary
Line 71: Line 71:
}
}
</syntaxhighlight>
</syntaxhighlight>




This method is called from these other places (same for BlockChest):
This method is called from these other places (same for BlockChest):


[[File:BlockAnvil setBlockBoundsBasedOnState.png|frameless|704x704px]]
[[File:BlockAnvil setBlockBoundsBasedOnState.png|frameless|704x704px]]




Notably, the following actions can be used for manipulation:
Notably, the following actions can be used for manipulation:
Line 82: Line 86:
* Causing the block to re-render, which can be done by updating the surroundings.
* Causing the block to re-render, which can be done by updating the surroundings.
* Using rain to update the block (randomly).
* Using rain to update the block (randomly).



== Limitations ==
== Limitations ==

Revision as of 10:24, 28 December 2020

Anvils don't have a fixed collision box. Instead there is exactly one universal collision box for all variants (North, East, South, West), which is updated whenever the player looks at one. Normal anvils, slightly damaged anvils, and very damaged anvils are not independent.

Chests behave in the same way, although only Double Chests have a different collision box. Chests and Trapped Chests are independent.


By standing next to an anvil/chest, and by looking at another variant, the player can update the collision box in such a way that there are now considered "inside the block". The same trick can be used to artificially extend the length of the anvil/chest, and manage to stand one or two pixels further than intended.

You must be careful not to look back at the original block, as that will reset the collision box to normal.



Top-view comparison of collision boxes


Anvils are a simple 1×0.75 bounding box (16×12 pixels), that can be oriented along the X or Z axis.

Single chests are a simple 0.875×0.875 bounding box (14×14 pixels). The "double chest" variant extends one side by 1 pixel.


In the graphic, darker colors indicate collision areas that are common to all variants : you should stand there in order not to fall during manipulation.

Lighter colors indicate collision areas that are specific to one variant: the player should stand there in order to clip into the block during manipulation.


Explanation

The BlockAnvil and BlockChest classes define the setBlockBoundsBasedOnState method as so:

/* In BlockAnvil.java */

public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
    EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);

    if (enumfacing.getAxis() == EnumFacing.Axis.X)
    {
        this.setBlockBounds(0.0F, 0.0F, 0.125F, 1.0F, 1.0F, 0.875F);
    }
    else
    {
        this.setBlockBounds(0.125F, 0.0F, 0.0F, 0.875F, 1.0F, 1.0F);
    }
}


/* In BlockChest.java */
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
    if (worldIn.getBlockState(pos.north()).getBlock() == this)
    {
        this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F);
    }
    else if (worldIn.getBlockState(pos.south()).getBlock() == this)
    {
        this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F);
    }
    else if (worldIn.getBlockState(pos.west()).getBlock() == this)
    {
        this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
    }
    else if (worldIn.getBlockState(pos.east()).getBlock() == this)
    {
        this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F);
    }
    else
    {
        this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
    }
}


This method is called from these other places (same for BlockChest):


Notably, the following actions can be used for manipulation:

  • Simply looking at the block (without necessarily drawing its selection box)
  • Shooting an arrow at the block (has a persistent effect).
  • Causing the block to re-render, which can be done by updating the surroundings.
  • Using rain to update the block (randomly).


Limitations

On Singleplayer, the player can usually walk through blocks once they clip into one (in this case, the manipulated anvil/chest).

On Multiplayer, the server will typically lagback the player when moving inside a block, unless they are less than 0.0625b away from the edge.


In 1.9, this mechanic was patched (each variant now has its own collision box).