diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPFlower1.java b/src/main/java/biomesoplenty/common/block/BlockBOPFlower1.java index a7cc5eba6..081dd1046 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPFlower1.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPFlower1.java @@ -105,23 +105,23 @@ public class BlockBOPFlower1 extends BlockDecoration { switch ((FlowerType) world.getBlockState(pos).getValue(VARIANT)) { case CLOVER: - this.setBlockBoundsByRadiusAndHeight(0.5F, 0.015625F); + this.setBlockBoundsByRadiusAndHeightWithXZOffset(0.5F, 0.015625F, pos); break; case ORANGE_COSMOS: - this.setBlockBoundsByRadiusAndHeight(0.2F, 0.8F); + this.setBlockBoundsByRadiusAndHeightWithXZOffset(0.2F, 0.8F, pos); break; case PINK_DAFFODIL: case DANDELION: - this.setBlockBoundsByRadiusAndHeight(0.2F, 0.6F); + this.setBlockBoundsByRadiusAndHeightWithXZOffset(0.2F, 0.6F, pos); break; case WHITE_ANEMONE: - this.setBlockBoundsByRadiusAndHeight(0.2F, 0.5F); + this.setBlockBoundsByRadiusAndHeightWithXZOffset(0.2F, 0.5F, pos); break; default: - this.setBlockBoundsByRadiusAndHeight(0.4F, 0.8F); + this.setBlockBoundsByRadiusAndHeightWithXZOffset(0.4F, 0.8F, pos); break; } } diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPFlower2.java b/src/main/java/biomesoplenty/common/block/BlockBOPFlower2.java index c142f0dc7..1fa1c0535 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPFlower2.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPFlower2.java @@ -93,7 +93,7 @@ public class BlockBOPFlower2 extends BlockDecoration { switch ((FlowerType) world.getBlockState(pos).getValue(VARIANT)) { default: - this.setBlockBoundsByRadiusAndHeight(0.4F, 0.8F); + this.setBlockBoundsByRadiusAndHeightWithXZOffset(0.4F, 0.8F, pos); break; } } diff --git a/src/main/java/biomesoplenty/common/block/BlockDecoration.java b/src/main/java/biomesoplenty/common/block/BlockDecoration.java index e71cf3bba..ccca4e234 100644 --- a/src/main/java/biomesoplenty/common/block/BlockDecoration.java +++ b/src/main/java/biomesoplenty/common/block/BlockDecoration.java @@ -63,12 +63,32 @@ public class BlockDecoration extends Block implements IBOPBlock // utility function for setting the block bounds - typically decoration blocks are smaller than full block size public void setBlockBoundsByRadiusAndHeight(float radius, float height) { - this.setBlockBoundsByRadiusAndHeight(radius,height,false); + this.setBlockBoundsByRadiusAndHeight(radius, height, false); } public void setBlockBoundsByRadiusAndHeight(float radius, float height, boolean fromTop) { this.setBlockBounds(0.5F - radius, (fromTop ? 1.0F - height : 0.0F), 0.5F - radius, 0.5F + radius, (fromTop ? 1.0F : height), 0.5F + radius); } + // some decoration blocks have a random XZ offset applied - if we set block bounds based on state, we may need these functions to correct for the offset + public void setBlockBoundsByRadiusAndHeightWithXZOffset(float radius, float height, BlockPos pos) + { + this.setBlockBoundsByRadiusAndHeightWithXZOffset(radius, height, false, pos); + } + public void setBlockBoundsByRadiusAndHeightWithXZOffset(float radius, float height, boolean fromTop, BlockPos pos) + { + // some Minecraft weirdness to get over here: in BlockModelRenderer there are 2 alternative quad drawers + // renderModelAmbientOcclusionQuads and renderModelStandardQuads, and they use very nearly but not quite the same functions for the XZ offset + // both versions rely on getting an unpredictable long 'hash' of the BlockPos coordinates + // the ambient one uses long i = MathHelper.getPositionRandom(pos) (which equates to long i = (long)(x * 3129871) ^ (long)z * 116129781L ^ (long)y; ) + // the standard one uses long i = (long)(x * 3129871) ^ (long)z * 116129781L; (no dependence on y) + // we use the standard one here, because that's the one being used to draw the plants + // it looks like a mistake to me. I think they probably intended to use MathHelper.getPositionRandom for both, but maybe there is some reason behind it + long i = (long)(pos.getX() * 3129871) ^ (long)pos.getZ() * 116129781L; + i = i * i * 42317861L + i * 11L; + float dx = (((float)(i >> 16 & 15L) / 15.0F) - 0.5F) * 0.5F; + float dz = (((float)(i >> 24 & 15L) / 15.0F) - 0.5F) * 0.5F; + this.setBlockBounds(0.5F - radius + dx, (fromTop ? 1.0F - height : 0.0F), 0.5F - radius + dz, 0.5F + radius + dx, (fromTop ? 1.0F : height), 0.5F + radius + dz); + } // add a canBlockStay() check before placing this block @Override