本文整理了Java中net.minecraft.util.math.AxisAlignedBB.calculateIntercept()
方法的一些代码示例,展示了AxisAlignedBB.calculateIntercept()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AxisAlignedBB.calculateIntercept()
方法的具体详情如下:
包路径:net.minecraft.util.math.AxisAlignedBB
类名称:AxisAlignedBB
方法名:calculateIntercept
暂无
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final RayTraceResult RayTraceResult = boundingBox.calculateIntercept( vec3, vec31 );
代码示例来源:origin: Vazkii/Botania
RayTraceResult rtr = player.getEntityBoundingBox().grow(0.25).calculateIntercept(origPos, newPos);
if(rtr != null)
player.attackEntityFrom(DamageSource.causeMobDamage(this), 6);
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final RayTraceResult RayTraceResult = boundingBox.calculateIntercept( Vec3d, Vec3d1 );
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final RayTraceResult RayTraceResult = boundingBox.calculateIntercept( Vec3d, Vec3d1 );
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public RayTraceResult calculateIntercept(Vec3d vec3_1, Vec3d vec3_2) {
return new AxisAlignedBB(minX, minY - yOffset, minZ, maxX, maxY, maxZ).calculateIntercept(vec3_1, vec3_2);
}
}
代码示例来源:origin: Vazkii/Botania
RayTraceResult raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
代码示例来源:origin: Vazkii/Botania
RayTraceResult raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
代码示例来源:origin: raoulvdberge/refinedstorage
public static AdvancedRayTraceResult<RayTraceResult> rayTrace(BlockPos pos, Vec3d start, Vec3d end, AxisAlignedBB bounds, int subHit, CollisionGroup group) {
RayTraceResult result = bounds.offset(pos).calculateIntercept(start, end);
if (result == null) {
return null;
}
result = new RayTraceResult(RayTraceResult.Type.BLOCK, result.hitVec, result.sideHit, pos);
result.subHit = subHit;
return new AdvancedRayTraceResult<>(group, bounds, result);
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
private static double getDistanceToCollidedEntity(Entity entity, Vec3d startVector, Vec3d endVector) {
float borderSize = entity.getCollisionBorderSize();
AxisAlignedBB entBB = entity.getEntityBoundingBox().grow((double) borderSize, (double) borderSize, (double) borderSize);
RayTraceResult rayTraceResult = entBB.calculateIntercept(startVector, endVector);
return rayTraceResult != null ? startVector.distanceTo(rayTraceResult.hitVec) : Double.MAX_VALUE;
}
代码示例来源:origin: TheGreyGhost/MinecraftByExample
/**
* Find the point [x,y,z] that corresponds to where the arrow has struck the face of the target
* @param arrow
* @param targetAABB
* @return
*/
private static Vec3d getArrowIntersectionWithTarget(EntityArrow arrow, AxisAlignedBB targetAABB)
{
// create a vector that points in the same direction as the arrow.
// Start with a vector pointing south - this corresponds to 0 degrees yaw and 0 degrees pitch
// Then rotate about the x-axis to pitch up or down, then rotate about the y axis to yaw
Vec3d arrowDirection = new Vec3d(0.0, 0.0, 10.0);
float rotationPitchRadians = (float)Math.toRadians(arrow.rotationPitch);
float rotationYawRadians = (float)Math.toRadians(arrow.rotationYaw);
arrowDirection = arrowDirection.rotatePitch(-rotationPitchRadians);
arrowDirection = arrowDirection.rotateYaw(+rotationYawRadians);
Vec3d arrowRayOrigin = arrow.getPositionVector();
Vec3d arrowRayEndpoint = arrowRayOrigin.add(arrowDirection);
RayTraceResult hitLocation = targetAABB.calculateIntercept(arrowRayOrigin, arrowRayEndpoint);
if (hitLocation == null) return null;
if (hitLocation.typeOfHit != RayTraceResult.Type.BLOCK) return null;
return hitLocation.hitVec;
}
代码示例来源:origin: McJtyMods/XNet
private RayTraceResult checkIntersect(BlockPos pos, Vec3d vec3d, Vec3d vec3d1, AxisAlignedBB boundingBox) {
RayTraceResult raytraceresult = boundingBox.calculateIntercept(vec3d, vec3d1);
return raytraceresult == null ? null : new RayTraceResult(raytraceresult.hitVec.addVector(pos.getX(), pos.getY(), pos.getZ()), raytraceresult.sideHit, pos);
}
代码示例来源:origin: Vazkii/Botania
float f = 1.0F;
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(f);
RayTraceResult RayTraceResult1 = axisalignedbb.calculateIntercept(vec3, vec31);
代码示例来源:origin: PrinceOfAmber/Cyclic
Vec3d b = end.subtract(x, y, z);
for (AxisAlignedBB box : boxes) {
RayTraceResult result = box.calculateIntercept(a, b);
if (result != null) {
Vec3d vec = result.hitVec.add(x, y, z);
代码示例来源:origin: MightyPirates/TIS-3D
@Nullable
private RayTraceResult checkEntityCollision(final World world, final Vec3d start, final Vec3d target) {
RayTraceResult entityHit = null;
double bestSqrDistance = Double.POSITIVE_INFINITY;
final List<Entity> collisions = world.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox().addCoord(motionX, motionY, motionZ));
for (final Entity entity : collisions) {
if (entity.canBeCollidedWith()) {
final AxisAlignedBB entityBounds = entity.getEntityBoundingBox();
final RayTraceResult hit = entityBounds.calculateIntercept(start, target);
if (hit != null) {
final double sqrDistance = start.squareDistanceTo(hit.hitVec);
if (sqrDistance < bestSqrDistance) {
hit.entityHit = entity;
hit.typeOfHit = RayTraceResult.Type.ENTITY;
entityHit = hit;
bestSqrDistance = sqrDistance;
}
}
}
}
return entityHit;
}
代码示例来源:origin: SquidDev-CC/plethora
@Nullable
@Override
@Deprecated
public RayTraceResult collisionRayTrace(IBlockState blockState, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Vec3d start, @Nonnull Vec3d end) {
ManipulatorType type = blockState.getValue(TYPE);
EnumFacing facing = blockState.getValue(FACING);
Vec3d startOff = start.subtract(pos.getX(), pos.getY(), pos.getZ());
Vec3d endOff = end.subtract(pos.getX(), pos.getY(), pos.getZ());
// Compute the intersection with the main box
AxisAlignedBB primary = getBoundingBox(blockState, world, pos);
RayTraceResult result = primary.calculateIntercept(startOff, endOff);
double distance = result == null ? Double.POSITIVE_INFINITY : result.hitVec.squareDistanceTo(startOff);
// Look for one of our inputs if possible.
for (AxisAlignedBB child : type.boxesFor(facing)) {
RayTraceResult hit = child.calculateIntercept(startOff, endOff);
if (hit != null) {
double newDistance = hit.hitVec.squareDistanceTo(startOff);
if (newDistance <= distance) {
result = hit;
distance = newDistance;
}
}
}
return result == null ? null : new RayTraceResult(result.hitVec.add(pos.getX(), pos.getY(), pos.getZ()), result.sideHit, pos);
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
for (Entity entity : list) {
AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().grow((double) entity.getCollisionBorderSize());
RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(positionEyes, vec3d2);
代码示例来源:origin: ForestryMC/ForestryMC
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
EnumFacing orientation = blockState.getValue(FACING);
List<AxisAlignedBB> boundingBoxes = boundingBoxesForDirections.get(orientation);
if (boundingBoxes == null) {
return super.collisionRayTrace(blockState, worldIn, pos, start, end);
}
RayTraceResult nearestIntersection = null;
for (AxisAlignedBB boundingBoxBase : boundingBoxes) {
AxisAlignedBB boundingBox = boundingBoxBase.offset(pos.getX(), pos.getY(), pos.getZ());
RayTraceResult intersection = boundingBox.calculateIntercept(start, end);
if (intersection != null) {
if (nearestIntersection == null || intersection.hitVec.distanceTo(start) < nearestIntersection.hitVec.distanceTo(start)) {
nearestIntersection = intersection;
}
}
}
if (nearestIntersection != null) {
Object hitInfo = nearestIntersection.hitInfo;
Entity entityHit = nearestIntersection.entityHit;
nearestIntersection = new RayTraceResult(nearestIntersection.typeOfHit, nearestIntersection.hitVec, nearestIntersection.sideHit, pos);
nearestIntersection.hitInfo = hitInfo;
nearestIntersection.entityHit = entityHit;
}
return nearestIntersection;
}
代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition
protected static DistanceRayTraceResult rayTraceBox(BlockPos pos, Vec3d start, Vec3d end, Cuboid box) {
Vec3d startRay = start.subtract(new Vec3d(pos));
Vec3d endRay = end.subtract(new Vec3d(pos));
RayTraceResult bbResult = box.aabb().calculateIntercept(startRay, endRay);
if (bbResult != null) {
Vec3d hitVec = bbResult.hitVec.add(new Vec3d(pos));
EnumFacing sideHit = bbResult.sideHit;
double dist = start.squareDistanceTo(hitVec);
return new DistanceRayTraceResult(hitVec, pos, sideHit, box, dist);
}
return null;
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
Entity entity1 = (Entity) list.get(j);
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow((double) entity1.getCollisionBorderSize() + 2F);
RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(vec3d, vec3d2);
代码示例来源:origin: RS485/LogisticsPipes
@Override
public RayTraceResult collisionRayTrace(IBlockState state, World world, BlockPos pos, Vec3d start, Vec3d end) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof PipeBlockRequestTable) {
Vec3d vec3d = start.subtract((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
Vec3d vec3d1 = end.subtract((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
RayTraceResult raytraceresult = FULL_BLOCK_AABB.calculateIntercept(vec3d, vec3d1);
return raytraceresult == null ? null : new RayTraceResult(raytraceresult.hitVec.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()), raytraceresult.sideHit, pos);
}
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe == null) { // Fallback for defect pipe
return rayTrace(pos, start, end, Block.FULL_BLOCK_AABB);
}
InternalRayTraceResult result = doRayTrace(world, pos, start, end);
if (result == null) {
return mcmpBlockAccess.collisionRayTrace(state, world, pos, start, end);
} else {
RayTraceResult secondResult = mcmpBlockAccess.collisionRayTrace(state, world, pos, start, end);
if(secondResult != null) {
if(secondResult.hitVec.distanceTo(start) < result.rayTraceResult.hitVec.distanceTo(start)) {
return secondResult;
}
}
return result.rayTraceResult;
}
}
内容来源于网络,如有侵权,请联系作者删除!