Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Block offset: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Sync: new page from Minecraft
 
SyncBot (talk | contribs)
Fix template calls: add MC/ prefix
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Partially conjecture}}
{{Partially conjecture}}
[[File:5x5 Grid of Poppies.png|thumb|A completely filled in 5 by 5 grid of [[poppies]], where each flower is subject to a block offset]]
[[File:5x5 Grid of Poppies.png|thumb|A completely filled in 5 by 5 grid of [[poppies]], where each flower is subject to a block offset]]
Certain non-solid blocks, such as [[Minecraft:short grass]], [[Minecraft:pointed dripstone]], and some [[Minecraft:flower]]s do not have their textures or hitboxes centered on blocks they are placed on, and are instead staggered in a {{w|Pseudorandomness|pseudorandom}} manner. The offset of a block depends solely on its X and Z coordinates, and not the world seed. This means that, for example, a row of flowers at the same coordinates will always be staggered the same way between worlds, and this will not be changed by a player breaking or replacing them.
Certain non-solid blocks, such as short grass, pointed dripstone, and some [[Minecraft:flower]]s do not have their textures or hitboxes centered on blocks they are placed on, and are instead staggered in a {{MC/W|Pseudorandomness|pseudorandom}} manner. The offset of a block depends solely on its X and Z coordinates, and not the world seed. This means that, for example, a row of flowers at the same coordinates will always be staggered the same way between worlds, and this will not be changed by a player breaking or replacing them.


All blocks with an offset have their hitbox and/or texture translated in the X and Z axis. Some blocks such as [[Minecraft:short grass]] or the [[Minecraft:fern]] additionally have an offset in the Y axis for their textures only. The base X, Y, and Z offsets of a block are consistent between all blocks at a certain coordinate. However, some blocks (such as [[Minecraft:bamboo]]{{Only|bedrock}} or [[Minecraft:pointed dripstone]]{{Only|java}}) may use the base offset slightly differently than most blocks for block placement.
All blocks with an offset have their hitbox and/or texture translated in the X and Z axis. Some blocks such as short grass or the [[Minecraft:fern]] additionally have an offset in the Y axis for their textures only. The base X, Y, and Z offsets of a block are consistent between all blocks at a certain coordinate. However, some blocks (such as [[Minecraft:bamboo]]{{Only|bedrock}} or pointed dripstone{{Only|java}}) may use the base offset slightly differently than most blocks for block placement.


== List of blocks subject to offset ==
== List of blocks subject to offset ==
Line 13: Line 13:
!Hitbox Y offset|| Texture Y offset
!Hitbox Y offset|| Texture Y offset
|-
|-
| {{BlockLink|Short Grass}}<br>{{BlockLink|Fern}}<br>{{BlockLink|Short Dry Grass}}<br>{{BlockLink|Tall Dry Grass}} || {{tc|Yes}} || {{tc|Yes}} ||  {{tc|partial|''Bedrock Edition'' only}} ||  {{tc|Yes}}
| {{MC/Blocklink|Short Grass}}<br>{{MC/Blocklink|Fern}}<br>{{MC/Blocklink|Short Dry Grass}}<br>{{MC/Blocklink|Tall Dry Grass}} || {{MC/Tc|Yes}} || {{MC/Tc|Yes}} ||  {{MC/Tc|partial|''Bedrock Edition'' only}} ||  {{MC/Tc|Yes}}
|-
|-
| {{BlockLink|Mangrove Propagule}}<br>{{BlockLink|Dandelion}}<br>{{BlockLink|Golden Dandelion}}<br>{{BlockLink|Torchflower}}<br>{{BlockLink|Poppy}}<br>{{BlockLink|Blue Orchid}}<br>{{BlockLink|Allium}}<br>{{BlockLink|Azure Bluet}}<br>{{BlockLink|Tulips}}<br>{{BlockLink|Oxeye Daisy}}<br>{{BlockLink|Cornflower}}<br>{{BlockLink|Wither Rose}}<br>{{BlockLink|Lily of the Valley}}<br>{{BlockLink|Bamboo Sapling}}<br>{{BlockLink|Bamboo}}<br>{{BlockLink|Pointed Dripstone}}|| {{tc|Yes}} || {{tc|Yes}} || {{tc|No}}|| {{tc|No}}
| {{MC/Blocklink|Mangrove Propagule}}<br>{{MC/Blocklink|Dandelion}}<br>{{MC/Blocklink|Golden Dandelion}}<br>{{MC/Blocklink|Torchflower}}<br>{{MC/Blocklink|Poppy}}<br>{{MC/Blocklink|Blue Orchid}}<br>{{MC/Blocklink|Allium}}<br>{{MC/Blocklink|Azure Bluet}}<br>{{MC/Blocklink|Tulips}}<br>{{MC/Blocklink|Oxeye Daisy}}<br>{{MC/Blocklink|Cornflower}}<br>{{MC/Blocklink|Wither Rose}}<br>{{MC/Blocklink|Lily of the Valley}}<br>{{MC/Blocklink|Bamboo Sapling}}<br>{{MC/Blocklink|Bamboo}}<br>{{MC/Blocklink|Pointed Dripstone}}|| {{MC/Tc|Yes}} || {{MC/Tc|Yes}} || {{MC/Tc|No}}|| {{MC/Tc|No}}
|-
|-
| {{BlockLink|Sunflower}}<br>{{BlockLink|Lilac}}<br>{{BlockLink|Rose Bush}}<br>{{BlockLink|Peony}}<br>{{BlockLink|Tall Grass}}<br>{{BlockLink|Large Fern}}<br>{{BlockLink|Pitcher Plant}}<br>{{BlockLink|Warped Roots}}<br>{{BlockLink|Nether Sprouts}}<br>{{BlockLink|Crimson Roots}}<br>{{BlockLink|Hanging Roots}} || {{tc|partial|''Bedrock Edition'' only}} || {{tc|Yes}} || {{tc|No}}|| {{tc|No}}
| {{MC/Blocklink|Sunflower}}<br>{{MC/Blocklink|Lilac}}<br>{{MC/Blocklink|Rose Bush}}<br>{{MC/Blocklink|Peony}}<br>{{MC/Blocklink|Tall Grass}}<br>{{MC/Blocklink|Large Fern}}<br>{{MC/Blocklink|Pitcher Plant}}<br>{{MC/Blocklink|Warped Roots}}<br>{{MC/Blocklink|Nether Sprouts}}<br>{{MC/Blocklink|Crimson Roots}}<br>{{MC/Blocklink|Hanging Roots}} || {{MC/Tc|partial|''Bedrock Edition'' only}} || {{MC/Tc|Yes}} || {{MC/Tc|No}}|| {{MC/Tc|No}}
|-  
|-  
| {{BlockLink|Coral Fans}}<br>{{BlockLink|Dead Coral Fans}} || {{tc|Partial| ''Bedrock Edition'' only}} || {{tc|Partial| ''Bedrock Edition'' only}} || {{tc|No}}|| {{tc|No}}
| {{MC/Blocklink|Coral Fans}}<br>{{MC/Blocklink|Dead Coral Fans}} || {{MC/Tc|Partial| ''Bedrock Edition'' only}} || {{MC/Tc|Partial| ''Bedrock Edition'' only}} || {{MC/Tc|No}}|| {{MC/Tc|No}}
|-
|-
| {{BlockLink|Coral}}<br>{{BlockLink|Dead Coral}} || {{tc|Partial|''Bedrock Edition'' only}} || {{tc|No}}<ref group="note">{{bug|MCPE-228149||Unlike the Coral fans, all Corals only have their hitbox randomly offcentered but not their block}}</ref> || {{tc|No}}|| {{tc|No}}
| {{MC/Blocklink|Coral}}<br>{{MC/Blocklink|Dead Coral}} || {{MC/Tc|Partial|''Bedrock Edition'' only}} || {{MC/Tc|No}}<ref group="note">{{bug|MCPE-228149||Unlike the Coral fans, all Corals only have their hitbox randomly offcentered but not their block}}</ref> || {{MC/Tc|No}}|| {{MC/Tc|No}}
|-
|-
| {{BlockLink|Tall Seagrass}} || {{tc|No}} || {{tc|Partial|''Java Edition'' only}}  
| {{MC/Blocklink|Tall Seagrass}} || {{MC/Tc|No}} || {{MC/Tc|Partial|''Java Edition'' only}}  
| {{tc|No}} || {{tc|No}}
| {{MC/Tc|No}} || {{MC/Tc|No}}
|-
|-
| {{BlockLink|Small Dripleaf}}||{{tc|No}} ||{{tc|Partial|''Java Edition'' only}}
| {{MC/Blocklink|Small Dripleaf}}||{{MC/Tc|No}} ||{{MC/Tc|Partial|''Java Edition'' only}}
| {{tc|No}} ||{{tc|Partial|''Java Edition'' only}}
| {{MC/Tc|No}} ||{{MC/Tc|Partial|''Java Edition'' only}}
|}
|}


== Effects of block offset on textures and hitboxes ==
== Effects of block offset on textures and hitboxes ==
{{Expand section}}
{{MC/Expand section}}
In {{JE}}, X and Z offsets are added to the coordinates of the center of the block to determine the new center of the texture or hitbox. In {{BE}}, X and Z offsets are used differently depending on the block. On both versions, the Y offset is directly added to the Y coordinate of the block to determine what Y level a texture will start. A Y offset will always be negative or zero, meaning a block's texture or hitbox may be translated downwards but never upwards.
In {{MC/JE}}, X and Z offsets are added to the coordinates of the center of the block to determine the new center of the texture or hitbox. In {{MC/BE}}, X and Z offsets are used differently depending on the block. On both versions, the Y offset is directly added to the Y coordinate of the block to determine what Y level a texture will start. A Y offset will always be negative or zero, meaning a block's texture or hitbox may be translated downwards but never upwards.


== Calculation of block offset ==
== Calculation of block offset ==
=== X and Z offset ===
=== X and Z offset ===
The following algorithm is used to calculate X and Z offsets of blocks (except for [[Minecraft:pointed dripstone]] in ''Java Edition'', given a block's X and Z coordinates.<ref name="offsetAlgorithm">From {{Java classpath|net.minecraft.world.level.block.state.BlockBehaviour}}#offsetType({{Java classpath|net.minecraft.world.level.block.state.BlockBehaviour.OffsetType}})</ref> Note that {{w|Two's complement|two's compliment arithmetic}} while treating all integers as signed 64 bit numbers must be used for correct results.<ref group="note">This corresponds to standard arithmetic operations involving the <code>long</code> datatype in {{wp|Java}}.</ref>
The following algorithm is used to calculate X and Z offsets of blocks (except for pointed dripstone in ''Java Edition'', given a block's X and Z coordinates.<ref name="offsetAlgorithm">From {{MC/Java classpath|net.minecraft.world.level.block.state.BlockBehaviour}}#offsetType({{MC/Java classpath|net.minecraft.world.level.block.state.BlockBehaviour.OffsetType}})</ref> Note that {{MC/W|Two's complement|two's compliment arithmetic}} while treating all integers as signed 64 bit numbers must be used for correct results.<ref group="note">This corresponds to standard arithmetic operations involving the <code>long</code> datatype in {{MC/WP|Java}}.</ref>
<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
temp1 = (0x2FC20F * x) XOR (0x6EBFFF5 * z)
temp1 = (0x2FC20F * x) XOR (0x6EBFFF5 * z)
Line 44: Line 44:
</syntaxhighlight>
</syntaxhighlight>


On ''Java Edition'', the X and Z offsets of pointed dripstone are given by calculating <code>x_offset</code> and <code>z_offset</code> above, and {{w|Clamp (function)|clamping}} the values between -0.125 and 0.125. All other blocks have their X and Z offsets clamped between -0.25 and 0.25.<ref group="note">The <code>y_offset</code> however is not clamped</ref>
On ''Java Edition'', the X and Z offsets of pointed dripstone are given by calculating <code>x_offset</code> and <code>z_offset</code> above, and {{MC/W|Clamp (function)|clamping}} the values between -0.125 and 0.125. All other blocks have their X and Z offsets clamped between -0.25 and 0.25.<ref group="note">The <code>y_offset</code> however is not clamped</ref>


=== Y offset ===
=== Y offset ===
The Y offset depends solely on the X and Z coordinates of a block and the block type. For all blocks with a Y offset besides [[Minecraft:small dripleaf]], the Y offset is given by (using the variable <code>temp2</code> from above):<ref name="offsetAlgorithm"/>
The Y offset depends solely on the X and Z coordinates of a block and the block type. For all blocks with a Y offset besides small dripleaf, the Y offset is given by (using the variable <code>temp2</code> from above):<ref name="offsetAlgorithm"/>
<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
y_offset = ((temp2 AND 0x0F00000) / 15.0 - 1.0) * 0.2
y_offset = ((temp2 AND 0x0F00000) / 15.0 - 1.0) * 0.2

Latest revision as of 19:56, 9 April 2026

Template:Partially conjecture

File:5x5 Grid of Poppies.png
A completely filled in 5 by 5 grid of poppies, where each flower is subject to a block offset

Certain non-solid blocks, such as short grass, pointed dripstone, and some Minecraft:flowers do not have their textures or hitboxes centered on blocks they are placed on, and are instead staggered in a

  1. REDIRECT Template:Wikipedia

Template:Redr manner. The offset of a block depends solely on its X and Z coordinates, and not the world seed. This means that, for example, a row of flowers at the same coordinates will always be staggered the same way between worlds, and this will not be changed by a player breaking or replacing them.

All blocks with an offset have their hitbox and/or texture translated in the X and Z axis. Some blocks such as short grass or the Minecraft:fern additionally have an offset in the Y axis for their textures only. The base X, Y, and Z offsets of a block are consistent between all blocks at a certain coordinate. However, some blocks (such as Minecraft:bambooTemplate:Only or pointed dripstoneTemplate:Only) may use the base offset slightly differently than most blocks for block placement.

List of blocks subject to offset

The following is a list of blocks subject to an offset in game. Most blocks have their hitbox offset to match their texture being offset, but some do not.

Blocks subject to offset
Block Hitbox XZ offset Texture XZ offset Hitbox Y offset Texture Y offset
  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr||

  1. REDIRECT Template:Table choice

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr||

  1. REDIRECT Template:Table choice

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr||

  1. REDIRECT Template:Table choice

Template:Redr

  1. redirect Template:blockLink

Template:Redr

  1. redirect Template:blockLink

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr<ref group="note">Template:Bug</ref> ||

  1. REDIRECT Template:Table choice

Template:Redr||

  1. REDIRECT Template:Table choice

Template:Redr

  1. redirect Template:blockLink

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr

  1. redirect Template:blockLink

Template:Redr||

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr

  1. REDIRECT Template:Table choice

Template:Redr ||

  1. REDIRECT Template:Table choice

Template:Redr

Effects of block offset on textures and hitboxes

Template:Message boxTemplate:Article other In Java Edition, X and Z offsets are added to the coordinates of the center of the block to determine the new center of the texture or hitbox. In Bedrock Edition, X and Z offsets are used differently depending on the block. On both versions, the Y offset is directly added to the Y coordinate of the block to determine what Y level a texture will start. A Y offset will always be negative or zero, meaning a block's texture or hitbox may be translated downwards but never upwards.

Calculation of block offset

X and Z offset

The following algorithm is used to calculate X and Z offsets of blocks (except for pointed dripstone in Java Edition, given a block's X and Z coordinates.<ref name="offsetAlgorithm">From {{#VARDEFINE:class name|BlockBehaviour}}Template:Tooltip#offsetType({{#VARDEFINE:class name|OffsetType}}Template:Tooltip)</ref> Note that

  1. REDIRECT Template:Wikipedia

Template:Redr while treating all integers as signed 64 bit numbers must be used for correct results.<ref group="note">This corresponds to standard arithmetic operations involving the long datatype in

  1. REDIRECT Template:Wikipedia

Template:Redr.</ref> <syntaxhighlight lang="c"> temp1 = (0x2FC20F * x) XOR (0x6EBFFF5 * z) temp2 = (0x285B825 * temp1 * temp1) + (0x000B * temp1) x_offset = ((temp2 AND 0x00F0000) / 15.0 - 0.5) * 0.5 z_offset = ((temp2 AND 0xF000000) / 15.0 - 0.5) * 0.5 </syntaxhighlight>

On Java Edition, the X and Z offsets of pointed dripstone are given by calculating x_offset and z_offset above, and

  1. REDIRECT Template:Wikipedia

Template:Redr the values between -0.125 and 0.125. All other blocks have their X and Z offsets clamped between -0.25 and 0.25.<ref group="note">The y_offset however is not clamped</ref>

Y offset

The Y offset depends solely on the X and Z coordinates of a block and the block type. For all blocks with a Y offset besides small dripleaf, the Y offset is given by (using the variable temp2 from above):<ref name="offsetAlgorithm"/> <syntaxhighlight lang="c"> y_offset = ((temp2 AND 0x0F00000) / 15.0 - 1.0) * 0.2 </syntaxhighlight> On Java Edition, the Y offset for small dripleaf is half as much as the Y offset for other blocks at the same coordinates.

Notes

Template:Notelist