本文整理匯總了Java中net.minecraft.util.math.AxisAlignedBB.isVecInside方法的典型用法代碼示例。如果您正苦於以下問題:Java AxisAlignedBB.isVecInside方法的具體用法?Java AxisAlignedBB.isVecInside怎麽用?Java AxisAlignedBB.isVecInside使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.util.math.AxisAlignedBB
的用法示例。
在下文中一共展示了AxisAlignedBB.isVecInside方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: actualRayTrace
import net.minecraft.util.math.AxisAlignedBB; //導入方法依賴的package包/類
public static Entity actualRayTrace(Entity entity, double dist)
{
Vec3d vec3d = entity.getPositionEyes(1.0F);
Vec3d vec3d1 = entity.getLook(1.0F);
Vec3d vec3d2 = vec3d.addVector(vec3d1.xCoord * dist, vec3d1.yCoord * dist, vec3d1.zCoord * dist);
Entity pointedEntity = null;
List<Entity> list = entity.worldObj.getEntitiesInAABBexcluding(entity, entity.getEntityBoundingBox().addCoord(vec3d1.xCoord * dist, vec3d1.yCoord * dist, vec3d1.zCoord * dist).expand(1.0D, 1.0D, 1.0D), Predicates.and(EntitySelectors.NOT_SPECTATING, new Predicate<Entity>()
{
public boolean apply(@Nullable Entity p_apply_1_)
{
return p_apply_1_ != null && p_apply_1_.canBeCollidedWith();
}
}));
for (int j = 0; j < list.size(); ++j)
{
Entity entity1 = (Entity)list.get(j);
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expandXyz((double)entity1.getCollisionBorderSize());
RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(vec3d, vec3d2);
if (axisalignedbb.isVecInside(vec3d))
{
if (dist >= 0.0D)
{
pointedEntity = entity1;
dist = 0.0D;
}
}
else if (raytraceresult != null)
{
double d3 = vec3d.distanceTo(raytraceresult.hitVec);
if (d3 < dist || dist == 0.0D)
{
if (entity1.getLowestRidingEntity() == entity.getLowestRidingEntity() && !entity.canRiderInteract())
{
if (dist == 0.0D)
{
pointedEntity = entity1;
}
}
else
{
pointedEntity = entity1;
dist = d3;
}
}
}
}
return pointedEntity;
}
示例2: onItemRightClick
import net.minecraft.util.math.AxisAlignedBB; //導入方法依賴的package包/類
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
float f1 = playerIn.prevRotationPitch + (playerIn.rotationPitch - playerIn.prevRotationPitch) * 1.0F;
float f2 = playerIn.prevRotationYaw + (playerIn.rotationYaw - playerIn.prevRotationYaw) * 1.0F;
double d0 = playerIn.prevPosX + (playerIn.posX - playerIn.prevPosX) * 1.0D;
double d1 = playerIn.prevPosY + (playerIn.posY - playerIn.prevPosY) * 1.0D + (double)playerIn.getEyeHeight();
double d2 = playerIn.prevPosZ + (playerIn.posZ - playerIn.prevPosZ) * 1.0D;
Vec3d vec3d = new Vec3d(d0, d1, d2);
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5;
float f8 = f3 * f5;
Vec3d vec3d1 = vec3d.addVector((double)f7 * 5.0D, (double)f6 * 5.0D, (double)f8 * 5.0D);
RayTraceResult raytraceresult = worldIn.rayTraceBlocks(vec3d, vec3d1, false);
if (raytraceresult == null)
{
return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
}
else
{
Vec3d vec3d2 = playerIn.getLook(1.0F);
boolean flag = false;
List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity(playerIn, playerIn.getEntityBoundingBox().addCoord(vec3d2.xCoord * 5.0D, vec3d2.yCoord * 5.0D, vec3d2.zCoord * 5.0D).expandXyz(1.0D));
for (int i = 0; i < list.size(); ++i)
{
Entity entity = list.get(i);
if (entity.canBeCollidedWith())
{
AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().expandXyz((double)entity.getCollisionBorderSize());
if (axisalignedbb.isVecInside(vec3d))
{
flag = true;
}
}
}
if (flag)
{
return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
}
else if (raytraceresult.typeOfHit != RayTraceResult.Type.BLOCK)
{
return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
}
else
{
EntityTractor entityTractor = new EntityTractor(worldIn, raytraceresult.hitVec.xCoord, raytraceresult.hitVec.yCoord, raytraceresult.hitVec.zCoord);
entityTractor.rotationYaw = playerIn.rotationYaw;
if (!worldIn.getCollisionBoxes(entityTractor, entityTractor.getEntityBoundingBox().expandXyz(-0.1D)).isEmpty())
{
return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
}
else
{
if (!worldIn.isRemote)
{
worldIn.spawnEntity(entityTractor);
}
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
}
}
}
}