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

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

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

World.rayTraceBlocks介绍

暂无

代码示例

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

  1. private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) {
  2. RayTraceResult mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D());
  3. if(mop == null)
  4. return prevresistance;
  5. if(mop.typeOfHit == RayTraceResult.Type.BLOCK) {
  6. Block block = world.getBlockState(mop.getBlockPos()).getBlock();
  7. if(world.isAirBlock(mop.getBlockPos()))
  8. return prevresistance;
  9. return prevresistance + block.getExplosionResistance(null) + 0.3F;
  10. } else return prevresistance;
  11. }

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

  1. public static RayTraceResult raytraceFromEntity(World worldIn, Entity playerIn, boolean useLiquids, double range) {
  2. float f = playerIn.rotationPitch;
  3. float f1 = playerIn.rotationYaw;
  4. double d0 = playerIn.posX;
  5. double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
  6. double d2 = playerIn.posZ;
  7. Vec3d vec3d = new Vec3d(d0, d1, d2);
  8. float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
  9. float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
  10. float f4 = -MathHelper.cos(-f * 0.017453292F);
  11. float f5 = MathHelper.sin(-f * 0.017453292F);
  12. float f6 = f3 * f4;
  13. float f7 = f2 * f4;
  14. double d3 = range; // Botania - use custom range param, don't limit to reach distance
  15. /*if (playerIn instanceof net.minecraft.entity.player.EntityPlayerMP)
  16. {
  17. d3 = ((net.minecraft.entity.player.EntityPlayerMP)playerIn).interactionManager.getBlockReachDistance();
  18. }*/
  19. Vec3d vec3d1 = vec3d.add((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
  20. return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
  21. }

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

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

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

  1. protected RayTraceResult raytraceFromEntity(World worldIn, EntityPlayer playerIn, boolean useLiquids) {
  2. float f = playerIn.rotationPitch;
  3. float f1 = playerIn.rotationYaw;
  4. double d0 = playerIn.posX;
  5. double d1 = playerIn.posY + (double) playerIn.getEyeHeight();
  6. double d2 = playerIn.posZ;
  7. Vec3d vec3d = new Vec3d(d0, d1, d2);
  8. float f2 = MathHelper.cos(-f1 * 0.017453292F - (float) Math.PI);
  9. float f3 = MathHelper.sin(-f1 * 0.017453292F - (float) Math.PI);
  10. float f4 = -MathHelper.cos(-f * 0.017453292F);
  11. float f5 = MathHelper.sin(-f * 0.017453292F);
  12. float f6 = f3 * f4;
  13. float f7 = f2 * f4;
  14. double d3 = 5.0D;
  15. if(playerIn instanceof net.minecraft.entity.player.EntityPlayerMP) {
  16. d3 = ((net.minecraft.entity.player.EntityPlayerMP) playerIn).interactionManager.getBlockReachDistance();
  17. }
  18. Vec3d vec3d1 = vec3d.add((double) f6 * d3, (double) f5 * d3, (double) f7 * d3);
  19. return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
  20. }

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

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

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

  1. @Override
  2. @Nullable
  3. public RayTraceResult rayTraceBlocks(@Nonnull Vec3d vec31, @Nonnull Vec3d vec32, boolean stopOnLiquid, boolean ignoreBlockWithoutBoundingBox,
  4. boolean returnLastUncollidableBlock) {
  5. return wrapped.rayTraceBlocks(vec31, vec32, stopOnLiquid, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock);
  6. }

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

  1. @Override
  2. @Nullable
  3. public RayTraceResult rayTraceBlocks(@Nonnull Vec3d start, @Nonnull Vec3d end) {
  4. return wrapped.rayTraceBlocks(start, end);
  5. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. @Override
  2. public void onUpdate() {
  3. Vec3d a = new Vec3d(this.posX, this.posY, this.posZ);
  4. Vec3d b = new Vec3d(this.posX + this.motionX * 1.5, this.posY + this.motionY * 1.5, this.posZ + this.motionZ * 1.5);
  5. RayTraceResult movingobjectposition = this.world.rayTraceBlocks(a, b, false, true, true);
  6. if (ticksInGround == 0 && movingobjectposition != null && movingobjectposition.entityHit == null){
  7. ticksInGround ++;
  8. onHitGround(movingobjectposition.getBlockPos());
  9. }
  10. super.onUpdate();
  11. }

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

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

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

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

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

  1. public static RayTraceResult rayTraceServer(Entity entity, double distance) {
  2. double eyeHeight = entity.posY + entity.getEyeHeight();
  3. Vec3d headVec = new Vec3d(entity.posX, eyeHeight, entity.posZ);
  4. Vec3d start = new Vec3d(headVec.x, headVec.y, headVec.z);
  5. Vec3d lookVec = entity.getLook(1.0F);
  6. headVec.add(new Vec3d(lookVec.x * distance, lookVec.y * distance, lookVec.z * distance));
  7. return entity.getEntityWorld().rayTraceBlocks(start, headVec, ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true));
  8. }
  9. }

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

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

相关文章

World类方法