Sei sulla pagina 1di 2

private static final AxisAlignedBB LOG_1 = new AxisAlignedBB(0, 0, 0.406, 1, 0.

188,
0.594);
// Skipped 'log_2', as it has roatation
// Skipped 'log_3', as it has roatation
private static final AxisAlignedBB LOG_4 = new AxisAlignedBB(0.406, 0, 0, 0.594,
0.188, 1);
private static final AxisAlignedBB POT_BASE = new AxisAlignedBB(0.125, 0.188,
0.125, 0.875, 0.25, 0.875);
private static final AxisAlignedBB POT_SIDE_EAST = new AxisAlignedBB(0.812, 0.25,
0.125, 0.875, 0.875, 0.875);
private static final AxisAlignedBB POT_SIDE_WEST = new AxisAlignedBB(0.125, 0.25,
0.125, 0.188, 0.875, 0.875);
private static final AxisAlignedBB POT_SIDE_SOUTH = new AxisAlignedBB(0.188, 0.25,
0.812, 0.812, 0.875, 0.875);
private static final AxisAlignedBB POT_SIDE_NORTH = new AxisAlignedBB(0.188, 0.25,
0.125, 0.812, 0.875, 0.188);
// Skipped 'handle_connection_one', as it has roatation
// Skipped 'handle_connection_two', as it has roatation
// Skipped 'handle', as it has roatation
/**
* AxisAlignedBBs and methods getBoundingBox, collisionRayTrace, and
collisionRayTrace generated using MrCrayfish's Model Creator <a
href="https://mrcrayfish.com/tools?id=mc">https://mrcrayfish.com/tools?id=mc</a>
*/
private static final List<AxisAlignedBB> COLLISION_BOXES =
Lists.newArrayList(LOG_1, LOG_4, POT_BASE, POT_SIDE_EAST, POT_SIDE_WEST,
POT_SIDE_SOUTH, POT_SIDE_NORTH);
private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0, 0, 0, 1,
0.875, 1);

@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source,
BlockPos pos)
{
return BOUNDING_BOX;
}

@Override
public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos,
AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity
entity, boolean isActualState)
{
entityBox = entityBox.offset(-pos.getX(), -pos.getY(), -pos.getZ());
for (AxisAlignedBB box : COLLISION_BOXES)
{
if (entityBox.intersects(box))
collidingBoxes.add(box.offset(pos));
}
}

@Override
@Nullable
public RayTraceResult collisionRayTrace(IBlockState state, World world, BlockPos
pos, Vec3d start, Vec3d end)
{
double distanceSq;
double distanceSqShortest = Double.POSITIVE_INFINITY;
RayTraceResult resultClosest = null;
RayTraceResult result;
start = start.subtract(pos.getX(), pos.getY(), pos.getZ());
end = end.subtract(pos.getX(), pos.getY(), pos.getZ());
for (AxisAlignedBB box : COLLISION_BOXES)
{
result = box.calculateIntercept(start, end);
if (result == null)
continue;

distanceSq = result.hitVec.squareDistanceTo(start);
if (distanceSq < distanceSqShortest)
{
distanceSqShortest = distanceSq;
resultClosest = result;
}
}
return resultClosest == null ? null : new
RayTraceResult(RayTraceResult.Type.BLOCK,
resultClosest.hitVec.addVector(pos.getX(), pos.getY(), pos.getZ()),
resultClosest.sideHit, pos);
}

Potrebbero piacerti anche