diff --git a/src/main/java/com/hbm/blocks/BlockDummyable.java b/src/main/java/com/hbm/blocks/BlockDummyable.java index 75dd39c2f..fa604e66e 100644 --- a/src/main/java/com/hbm/blocks/BlockDummyable.java +++ b/src/main/java/com/hbm/blocks/BlockDummyable.java @@ -26,6 +26,8 @@ import net.minecraft.stats.StatList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.client.event.DrawBlockHighlightEvent; @@ -467,6 +469,33 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl return AxisAlignedBB.getBoundingBox(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ).offset(x + 0.5, y + 0.5, z + 0.5); } + @Override + public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) { + if(!this.useDetailedHitbox()) { + return super.collisionRayTrace(world, x, y, z, startVec, endVec); + } + + int[] pos = this.findCore(world, x, y, z); + + if(pos == null) + return super.collisionRayTrace(world, x, y, z, startVec, endVec); + + x = pos[0]; + y = pos[1]; + z = pos[2]; + + for(AxisAlignedBB aabb :this.bounding) { + AxisAlignedBB boxlet = getAABBRotationOffset(aabb, x + 0.5, y, z + 0.5, ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) - offset).getRotation(ForgeDirection.UP)); + + MovingObjectPosition intercept = boxlet.calculateIntercept(startVec, endVec); + if(intercept != null) { + return new MovingObjectPosition(x, y, z, intercept.sideHit, intercept.hitVec); + } + } + + return null; + } + @Override public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { if(!this.useDetailedHitbox()) {