net.minecraft.world.World.rayTraceBlocks()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中net.minecraft.world.World.rayTraceBlocks()方法的一些代码示例,展示了World.rayTraceBlocks()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.rayTraceBlocks()方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:rayTraceBlocks

World.rayTraceBlocks介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) {
  RayTraceResult mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D());
  if(mop == null)
    return prevresistance;
  if(mop.typeOfHit == RayTraceResult.Type.BLOCK) {
    Block block = world.getBlockState(mop.getBlockPos()).getBlock();
    if(world.isAirBlock(mop.getBlockPos()))
      return prevresistance;
    return prevresistance + block.getExplosionResistance(null) + 0.3F;
  } else return prevresistance;
}

代码示例来源:origin: Vazkii/Botania

public static RayTraceResult raytraceFromEntity(World worldIn, Entity playerIn, boolean useLiquids, double range) {
  float f = playerIn.rotationPitch;
  float f1 = playerIn.rotationYaw;
  double d0 = playerIn.posX;
  double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
  double d2 = playerIn.posZ;
  Vec3d vec3d = new Vec3d(d0, d1, d2);
  float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
  float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
  float f4 = -MathHelper.cos(-f * 0.017453292F);
  float f5 = MathHelper.sin(-f * 0.017453292F);
  float f6 = f3 * f4;
  float f7 = f2 * f4;
  double d3 = range; // Botania - use custom range param, don't limit to reach distance
  /*if (playerIn instanceof net.minecraft.entity.player.EntityPlayerMP)
  {
    d3 = ((net.minecraft.entity.player.EntityPlayerMP)playerIn).interactionManager.getBlockReachDistance();
  }*/
  Vec3d vec3d1 = vec3d.add((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
  return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

pos = w.rayTraceBlocks( vec3, vec31, true );

代码示例来源:origin: Vazkii/Botania

protected RayTraceResult raytraceFromEntity(World worldIn, EntityPlayer playerIn, boolean useLiquids) {
  float f = playerIn.rotationPitch;
  float f1 = playerIn.rotationYaw;
  double d0 = playerIn.posX;
  double d1 = playerIn.posY + (double) playerIn.getEyeHeight();
  double d2 = playerIn.posZ;
  Vec3d vec3d = new Vec3d(d0, d1, d2);
  float f2 = MathHelper.cos(-f1 * 0.017453292F - (float) Math.PI);
  float f3 = MathHelper.sin(-f1 * 0.017453292F - (float) Math.PI);
  float f4 = -MathHelper.cos(-f * 0.017453292F);
  float f5 = MathHelper.sin(-f * 0.017453292F);
  float f6 = f3 * f4;
  float f7 = f2 * f4;
  double d3 = 5.0D;
  if(playerIn instanceof net.minecraft.entity.player.EntityPlayerMP) {
    d3 = ((net.minecraft.entity.player.EntityPlayerMP) playerIn).interactionManager.getBlockReachDistance();
  }
  Vec3d vec3d1 = vec3d.add((double) f6 * d3, (double) f5 * d3, (double) f7 * d3);
  return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
}

代码示例来源:origin: SleepyTrousers/EnderIO

private boolean isClear(@Nonnull Vec3d startPos, @Nonnull Vec3d target) {
 RayTraceResult hit = world.rayTraceBlocks(startPos, target, true, true, false);
 return hit == null || hit.typeOfHit == RayTraceResult.Type.MISS;
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
@Nullable
public RayTraceResult rayTraceBlocks(@Nonnull Vec3d vec31, @Nonnull Vec3d vec32, boolean stopOnLiquid, boolean ignoreBlockWithoutBoundingBox,
  boolean returnLastUncollidableBlock) {
 return wrapped.rayTraceBlocks(vec31, vec32, stopOnLiquid, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock);
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
@Nullable
public RayTraceResult rayTraceBlocks(@Nonnull Vec3d start, @Nonnull Vec3d end) {
 return wrapped.rayTraceBlocks(start, end);
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
@Nullable
public RayTraceResult rayTraceBlocks(@Nonnull Vec3d start, @Nonnull Vec3d end, boolean stopOnLiquid) {
 return wrapped.rayTraceBlocks(start, end, stopOnLiquid);
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

RayTraceResult pos = w.rayTraceBlocks( Vec3d, Vec3d1, true );
if( entity != null && pos != null && pos.hitVec.squareDistanceTo( vec ) > closest )

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

RayTraceResult pos = w.rayTraceBlocks( Vec3d, Vec3d1, false );

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

/**
   * Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
   * pos1, pos2, entityXSize, entityYSize, entityZSize
   */
  @Override
  protected boolean isDirectPathBetweenPoints(Vec3d pos1, Vec3d pos2, int sizeX, int sizeY, int sizeZ) {
    RayTraceResult movingobjectposition = this.world.rayTraceBlocks(pos1, new Vec3d(pos2.x, pos2.y + (double) this.entity.height * 0.5D, pos2.z), false, true, false);
    return movingobjectposition == null || movingobjectposition.typeOfHit == RayTraceResult.Type.MISS;
  }
}

代码示例来源:origin: Vazkii/Botania

RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d, vec3d1);
vec3d = new Vec3d(this.posX, this.posY, this.posZ);
vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

代码示例来源:origin: Vazkii/Botania

RayTraceResult raytraceresult = world.rayTraceBlocks(vec3d, vec3d1);
vec3d = new Vec3d(posX, posY, posZ);
vec3d1 = new Vec3d(posX + motionX, posY + motionY, posZ + motionZ);

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

from = from.addVector( direction.getFrontOffsetX() * 0.501, direction.getFrontOffsetY() * 0.501, direction.getFrontOffsetZ() * 0.501 );
final Vec3d to = from.addVector( direction.getFrontOffsetX(), direction.getFrontOffsetY(), direction.getFrontOffsetZ() );
final RayTraceResult mop = hostWorld.rayTraceBlocks( from, to, true );
if( mop != null && !BAD_BLOCKS.contains( directedBlock ) )

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

private static RayTraceResult getPlayerLookTargetClient(EntityPlayer player, Entity excludedEntity) {
  Vec3d playerEyesPos = RayTracer.getCorrectedHeadVec(player);
  Vec3d lookVector = player.getLook(0);
  Vec3d endVector = playerEyesPos.addVector(lookVector.x * MAX_RANGE, lookVector.y * MAX_RANGE, lookVector.z * MAX_RANGE);
  RayTraceResult blockHit = player.world.rayTraceBlocks(playerEyesPos, endVector);
  Optional<Tuple<Double, Entity>> closestEntityFound = getClosestCollidedEntity(excludedEntity, playerEyesPos, lookVector, endVector);
  if (closestEntityFound.isPresent() && (blockHit == null || closestEntityFound.get().getFirst() < blockHit.hitVec.distanceTo(playerEyesPos))) {
    Entity hitEntity = closestEntityFound.get().getSecond();
    blockHit = new RayTraceResult(hitEntity, new Vec3d(hitEntity.posX, hitEntity.posY + hitEntity.height * 0.65d, hitEntity.posZ));
  }
  return blockHit;
}

代码示例来源:origin: Mine-and-blade-admin/Battlegear2

@Override
public void onUpdate() {
  Vec3d a = new Vec3d(this.posX, this.posY, this.posZ);
  Vec3d b = new Vec3d(this.posX + this.motionX * 1.5, this.posY + this.motionY * 1.5, this.posZ + this.motionZ * 1.5);
  RayTraceResult movingobjectposition = this.world.rayTraceBlocks(a, b, false, true, true);
  if (ticksInGround == 0 && movingobjectposition != null && movingobjectposition.entityHit == null){
    ticksInGround ++;
    onHitGround(movingobjectposition.getBlockPos());
  }
  super.onUpdate();
}

代码示例来源:origin: Vazkii/Botania

Vec3d vec31 = new Vec3d(posX + motionX, posY + motionY, posZ + motionZ);
RayTraceResult RayTraceResult = world.rayTraceBlocks(vec3, vec31);

代码示例来源:origin: TehNut/HWYLA

public RayTraceResult rayTrace(Entity entity, double playerReach, float partialTicks) {
  Vec3d eyePosition = entity.getPositionEyes(partialTicks);
  Vec3d lookVector = entity.getLook(partialTicks);
  Vec3d traceEnd = eyePosition.addVector(lookVector.x * playerReach, lookVector.y * playerReach, lookVector.z * playerReach);
  return entity.getEntityWorld().rayTraceBlocks(eyePosition, traceEnd, ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true));
}

代码示例来源:origin: TehNut/HWYLA

public static RayTraceResult rayTraceServer(Entity entity, double distance) {
    double eyeHeight = entity.posY + entity.getEyeHeight();
    Vec3d headVec = new Vec3d(entity.posX, eyeHeight, entity.posZ);
    Vec3d start = new Vec3d(headVec.x, headVec.y, headVec.z);
    Vec3d lookVec = entity.getLook(1.0F);
    headVec.add(new Vec3d(lookVec.x * distance, lookVec.y * distance, lookVec.z * distance));

    return entity.getEntityWorld().rayTraceBlocks(start, headVec, ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true));
  }
}

代码示例来源:origin: SleepyTrousers/EnderIO

private boolean canJoeSee(EntityLivingBase ent) {
 Vec3d entPos = new Vec3d(ent.posX, ent.posY + ent.getEyeHeight(), ent.posZ);
 for (EnumFacing facing1 : new EnumFacing[] { facing, facing.rotateY(), facing.rotateYCCW() }) {
  if (this.world.rayTraceBlocks(new Vec3d(getPos().getX() + faceMidPoints[facing1.ordinal()][0], getPos().getY() + faceMidPoints[facing1.ordinal()][1],
    getPos().getZ() + faceMidPoints[facing1.ordinal()][2]), entPos) == null)
   return true;
 }
 return false;
}

相关文章

微信公众号

最新文章

更多

World类方法