Minecraft:Block offset: Difference between revisions
More actions
Sync: updated from Minecraft |
Sync: updated from Minecraft |
||
| (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 | Certain non-solid blocks, such as [[Minecraft:short grass]], [[Minecraft:pointed dripstone]], and some [[Minecraft:flower]]s do not have their textures or interaction boxes 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 [[Minecraft: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 [[Minecraft:player]] breaking or replacing them. | ||
All blocks with an offset have their | All blocks with an offset have their [[Minecraft:interaction box]] 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. | ||
== List of blocks subject to offset == | == List of blocks subject to offset == | ||
The following is a list of blocks subject to an offset in game. Most blocks have their | The following is a list of blocks subject to an offset in game. Most blocks have their interaction box offset to match their texture being offset, but some do not. | ||
{| class="wikitable" | {| class="wikitable" | ||
|+ Blocks subject to offset | |+ Blocks subject to offset | ||
|- | |- | ||
! Block !! | ! Block !! Interaction box XZ offset || Texture XZ offset | ||
! | !Interaction box 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}} | | {{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}} | ||
| Line 33: | Line 32: | ||
== Effects of block offset on textures and hitboxes == | == Effects of block offset on textures and hitboxes == | ||
{{Expand section}} | {{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 | 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 interaction box may be translated downwards but never upwards. | ||
== Calculation of block offset == | == Calculation of block offset == | ||
| Line 60: | Line 59: | ||
== Notes == | == Notes == | ||
{{notelist}} | {{notelist}} | ||
== References == | |||
{{reflist}} | |||
== Navigation == | |||
{{Navbox gameplay}} | |||
[[Category:Research required]] | [[Category:Research required]] | ||
Latest revision as of 11:03, 20 August 2026
Certain non-solid blocks, such as Minecraft:short grass, Minecraft:pointed dripstone, and some Minecraft:flowers do not have their textures or interaction boxes centered on blocks they are placed on, and are instead staggered in a Template:W manner. The offset of a block depends solely on its X and Z coordinates, and not the Minecraft: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 Minecraft:player breaking or replacing them.
All blocks with an offset have their Minecraft:interaction box 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:bambooTemplate:Only or Minecraft: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 interaction box offset to match their texture being offset, but some do not.
Effects of block offset on textures and hitboxes
Template:Expand section In Template: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 Template: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 interaction box 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 in Java Edition (except for Minecraft:pointed dripstone and Minecraft:sulfur spikes), given a block's X and Z coordinates.<ref name="offsetAlgorithm">From Template:Java classpath#offsetType(Template:Java classpath)</ref> Note that Template:W 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 Template:Wp.</ref>
<syntaxhighlight lang="c">
temp1 = (0x2FC20F * x) XOR (0x6EBFFF5 * z)
temp2 = (0x285B825 * temp1 * temp1) + (0x000B * temp1)
x_offset = (((temp2 >> 16) AND 0xF) / 15.0 - 0.5) * 0.5
z_offset = (((temp2 >> 24) AND 0xF) / 15.0 - 0.5) * 0.5
</syntaxhighlight>
The X and Z offsets of pointed dripstone and sulfur spikes are given by calculating the x_offset and z_offset above, and Template:W 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 in Java Edition 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 temp2 from above):<ref name="offsetAlgorithm"/>
<syntaxhighlight lang="c">
y_offset = (((temp2 >> 20) AND 0xF) / 15.0 - 1.0) * 0.2
</syntaxhighlight>
The Y offset for small dripleaf is half as much as the Y offset for other blocks at the same coordinates.