net.minecraft.entity.Entity.rayTrace()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(121)

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

Entity.rayTrace介绍

暂无

代码示例

代码示例来源:origin: PrinceOfAmber/Cyclic

@SideOnly(Side.CLIENT)
@Override
public EnumFacing getSideMouseover(int max) {
 RayTraceResult mouseOver = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(max, 1f);
 // now get whatever block position we are mousing over if anything
 if (mouseOver != null) {
  // Get the block position and make sure it is a block
  return mouseOver.sideHit;
 }
 return null;
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@SideOnly(Side.CLIENT)
@Override
public BlockPos getBlockMouseoverExact(int max) {
 // Get the player and their held item
 RayTraceResult mouseOver = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(max, 1f);
 // now get whatever block position we are mousing over if anything
 if (mouseOver != null) {
  // Get the block position and make sure it is a block
  return mouseOver.getBlockPos();
 }
 return null;
}

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

@SideOnly(Side.CLIENT)
private Optional<RayTraceResult> getMouseOverExtended(float reach) {
  RayTraceResult ret = null;
  Minecraft mc = Minecraft.getMinecraft();
  Entity renderViewEntity = mc.getRenderViewEntity();
  if (renderViewEntity != null && mc.world != null) {
    mc.mcProfiler.startSection("pick");
    double d0 = reach;
    ret = renderViewEntity.rayTrace(d0, 0);
    Vec3d positionEyes = renderViewEntity.getPositionEyes(0);
    double calcDist = d0;
    if (ret != null) {
      calcDist = ret.hitVec.distanceTo(positionEyes);
    }
    Vec3d vec3d1 = renderViewEntity.getLook(1.0F);
    Vec3d vec3d2 = positionEyes.addVector(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0);
    List<Entity> list = mc.world.getEntitiesInAABBexcluding(renderViewEntity,
        renderViewEntity.getEntityBoundingBox().expand(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0).grow(1.0D, 1.0D, 1.0D),
        Predicates.and(EntitySelectors.NOT_SPECTATING, e -> e != null && e.canBeCollidedWith()));
    ret = getEntityHit(ret, renderViewEntity, positionEyes, calcDist, vec3d2, list);
  }
  return Optional.ofNullable(ret);
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@SideOnly(Side.CLIENT)
@Override
public BlockPos getBlockMouseoverOffset(int max) {
 // Get the player and their held item
 EntityPlayerSP player = (EntityPlayerSP) getClientPlayer();
 // int max = 50;
 RayTraceResult mouseOver = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(max, 1f);
 // now get whatever block position we are mousing over if anything
 if (mouseOver != null && mouseOver.sideHit != null) {
  // Get the block position and make sure it is a block
  // World world = player.worldObj;
  BlockPos blockPos = mouseOver.getBlockPos();
  if (blockPos != null && player != null && player.getEntityWorld().getBlockState(blockPos) != null
    && player.getEntityWorld().isAirBlock(blockPos) == false) {
   return blockPos.offset(mouseOver.sideHit);
  }
 }
 return null;
}

代码示例来源:origin: thraaawn/CompactMachines

RayTraceResult rayTraceResult = sender.getCommandSenderEntity().rayTrace(16.0f, 0.0f);
if(rayTraceResult.typeOfHit != RayTraceResult.Type.BLOCK) {
  throw this.getException(sender, "look_at_compact_machine");

代码示例来源:origin: CoFH/CoFHCore

RayTraceResult traceResult = renderEntity.rayTrace(distance, event.getPartialTicks());
if (traceResult != null) {
  ImmutableList<BlockPos> extraBlocks = aoeTool.getAOEBlocks(stack, traceResult.getBlockPos(), player);

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

RayTraceResult objectMouseOver = mc.getRenderViewEntity().rayTrace(d0, tickPart);
double d1 = d0;
Vec3d vec3 = mc.getRenderViewEntity().getPositionEyes(tickPart);

代码示例来源:origin: jabelar/ExampleMod-1.12

returnMOP = theRenderViewEntity.rayTrace(var2, 0);
double calcdist = var2;
Vec3d pos = theRenderViewEntity.getPositionEyes(0);

代码示例来源:origin: PenguinSquad/Harvest-Festival

@SubscribeEvent
public void renderExtraBlockBreak(RenderWorldLastEvent event) {
  PlayerControllerMP controller = MCClientHelper.getPlayerController();
  EntityPlayer player = MCClientHelper.getPlayer();
  World world = player.world;
  ItemStack tool = player.getHeldItemMainhand();
  if (tool != null && (tool.getItem() == HFTools.HAMMER || tool.getItem() == HFTools.HOE)) {
    Entity renderEntity = MCClientHelper.getRenderViewEntity();
    double distance = controller.getBlockReachDistance();
    RayTraceResult rayTraceResult = renderEntity.rayTrace(distance, event.getPartialTicks());
    if (rayTraceResult != null) {
      if (tool.getItem() == HFTools.HAMMER && HFTools.HAMMER.canUse(tool)) {
        ImmutableList<BlockPos> extraBlocks = HFTools.HAMMER.getBlocks(world, rayTraceResult.getBlockPos(), player, tool);
        drawSelection(event.getContext(), extraBlocks, player, event.getPartialTicks());
        if (controller.getIsHittingBlock()) {
          drawBlockDamageTexture(MCClientHelper.getMinecraft().renderGlobal, controller,
              Tessellator.getInstance(), Tessellator.getInstance().getBuffer(),
              player, event.getPartialTicks(), world, extraBlocks);
        }
      } else if (tool.getItem() == HFTools.HOE && HFTools.HOE.canUse(tool)) {
        drawSelection(event.getContext(), HFTools.HOE.getBlocks(world, rayTraceResult.getBlockPos(), player, tool), player, event.getPartialTicks());
      }
    }
  }
}

代码示例来源:origin: vadis365/TheErebus

RayTraceResult mop = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(5, 1.0F);
if(mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
  Erebus.NETWORK_WRAPPER.sendToServer(new PacketBeetleDig(mop.getBlockPos(), mop.sideHit));

相关文章

Entity类方法