@Override /** * Ray traces through the blocks collision from start vector to end vector returning a ray trace * hit. Args: world, x, y, z, startVec, endVec */ public MovingObjectPosition collisionRayTrace( World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) { TEBase TE = getTileEntity(world, x, y, z); MovingObjectPosition finalTrace = null; if (TE != null) { Slope slope = Slope.slopesList[TE.getData()]; SlopeUtil slopeUtil = new SlopeUtil(); int numPasses = slopeUtil.getNumPasses(slope); int precision = slopeUtil.getNumBoxesPerPass(slope); rayTracing = true; /* Determine if ray trace is a hit on slope. */ for (int pass = 0; pass < numPasses; ++pass) { for (int slice = 0; slice < precision && finalTrace == null; ++slice) { float[] box = slopeUtil.genBounds(slope, slice, precision, pass); if (box != null) { setBlockBounds(box[0], box[1], box[2], box[3], box[4], box[5]); finalTrace = super.collisionRayTrace(world, x, y, z, startVec, endVec); } } if (slope.type.equals(Type.OBLIQUE_EXT)) { --precision; } } rayTracing = false; /* Determine true face hit since sloped faces are two or more shared faces. */ if (finalTrace != null) { setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); finalTrace = super.collisionRayTrace(world, x, y, z, startVec, endVec); } } return finalTrace; }
@Override /** * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they * intersect the mask.) Parameters: World, X, Y, Z, mask, list, colliding entity */ public void addCollisionBoxesToList( World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, List list, Entity entity) { TEBase TE = getTileEntity(world, x, y, z); if (TE != null) { AxisAlignedBB box = null; Slope slope = Slope.slopesList[TE.getData()]; SlopeUtil slopeUtil = new SlopeUtil(); int precision = slopeUtil.getNumBoxesPerPass(slope); int numPasses = slopeUtil.getNumPasses(slope); for (int pass = 0; pass < numPasses; ++pass) { for (int slice = 0; slice < precision; ++slice) { float[] dim = slopeUtil.genBounds(slope, slice, precision, pass); if (dim != null) { box = AxisAlignedBB.getBoundingBox( x + dim[0], y + dim[1], z + dim[2], x + dim[3], y + dim[4], z + dim[5]); } if (box != null && axisAlignedBB.intersectsWith(box)) { list.add(box); } } if (slope.type.equals(Type.OBLIQUE_EXT)) { --precision; } } } }