private static RayTraceResult rayTrace2(BlockPos pos, Vec3d start, Vec3d end, AxisAlignedBB boundingBox) { 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 = boundingBox.calculateIntercept(vec3d, vec3d1); return raytraceresult == null ? null : new RayTraceResult(raytraceresult.hitVec.addVector((double) pos.getX(), (double) pos.getY(), (double) pos.getZ()), raytraceresult.sideHit, pos); }
return new RayTraceResult(pointedEntity, hit);
@Override public void onUpdate() { super.onUpdate(); float dist = 1.5F; for(int i = 0; i < 10; i++) { float xs = (float) (Math.random() - 0.5) * dist; float ys = (float) (Math.random() - 0.5) * dist; float zs = (float) (Math.random() - 0.5) * dist; Botania.proxy.sparkleFX(posX + xs, posY + ys, posZ + zs, 1F, 0.4F, 1F, 2F, 6); } EntityLivingBase thrower = getThrower(); if(!world.isRemote && thrower != null) { AxisAlignedBB axis = new AxisAlignedBB(posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ).grow(2); List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, axis); for(EntityLivingBase living : entities) { if(living == thrower) continue; if(living.hurtTime == 0) { onImpact(new RayTraceResult(living)); return; } } } if(ticksExisted > 200) setDead(); }
pos = new RayTraceResult( entity ); pos = new RayTraceResult( entity );
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) { if(player.isSneaking()) { Block block = world.getBlockState(pos).getBlock(); if(block != null) { if(block instanceof ILexiconable) { ItemStack stack = player.getHeldItem(hand); LexiconEntry entry = ((ILexiconable) block).getEntry(world, pos, player, stack); if(entry != null && isKnowledgeUnlocked(stack, entry.getKnowledgeType())) { Botania.proxy.setEntryToOpen(entry); Botania.proxy.setLexiconStack(stack); openBook(player, stack, world, false); return EnumActionResult.SUCCESS; } } else if(world.isRemote) { RayTraceResult mop = new RayTraceResult(new Vec3d(par8, par9, par10), side, pos); return Botania.proxy.openWikiPage(world, block, mop) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; } } } return EnumActionResult.PASS; }
if( entity != null && pos != null && pos.hitVec.squareDistanceTo( vec ) > closest ) pos = new RayTraceResult( entity ); pos = new RayTraceResult( entity );
@Override public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand ) { final RayTraceResult mop = new RayTraceResult( new Vec3d( hitX, hitY, hitZ ), side, pos ); final TileEntity te = world.getTileEntity( pos ); if( te instanceof IPartHost ) { final SelectedPart part = ( (IPartHost) te ).selectPart( mop.hitVec ); if( part.part != null || part.facade != null ) { if( part.part instanceof INetworkToolAgent && !( (INetworkToolAgent) part.part ).showNetworkInfo( mop ) ) { return EnumActionResult.FAIL; } else if( player.isSneaking() ) { return EnumActionResult.PASS; } } } else if( te instanceof INetworkToolAgent && !( (INetworkToolAgent) te ).showNetworkInfo( mop ) ) { return EnumActionResult.FAIL; } if( Platform.isClient() ) { NetworkHandler.instance().sendToServer( new PacketClick( pos, side, hitX, hitY, hitZ, hand ) ); } return EnumActionResult.SUCCESS; }
if( entity != null && pos != null && pos.hitVec.squareDistanceTo( vec ) > closest ) pos = new RayTraceResult( entity ); pos = new RayTraceResult( entity );
raytraceResult = new RayTraceResult(entity);
ImmutableList<BlockPos> extraBlocks = ((IAoeTool) tool.getItem()).getAOEBlocks(tool, world, player, mop.getBlockPos()); for(BlockPos pos : extraBlocks) { event.getContext().drawSelectionBox(player, new RayTraceResult(new Vec3d(0, 0, 0), null, pos), 0, event.getPartialTicks());
raytraceresult = new RayTraceResult(entity);
raytraceresult = new RayTraceResult(entity);
living.attackEntityFrom(DamageSource.causePlayerDamage(player), 20); else living.attackEntityFrom(DamageSource.GENERIC, 20); onImpact(new RayTraceResult(living)); return;
@Override public void used(@Nonnull EnumHand hand, @Nonnull EntityPlayer player, @Nonnull BlockPos pos) { ItemStack stack = player.getHeldItem(hand); ((IToolWrench) stack.getItem()).wrenchUsed(player, hand, stack, new RayTraceResult(new Vec3d(pos), EnumFacing.UP, pos)); }
@Override public boolean canUse(@Nonnull EnumHand hand, @Nonnull EntityPlayer player, @Nonnull BlockPos pos) { ItemStack stack = player.getHeldItem(hand); return ((IToolWrench) stack.getItem()).canWrench(player, hand, stack, new RayTraceResult(new Vec3d(pos), EnumFacing.UP, pos)); }
private void drawSelection(RenderGlobal render, ImmutableList<BlockPos> extraBlocks, EntityPlayer player, float ticks) { for (BlockPos pos : extraBlocks) { render.drawSelectionBox(player, new RayTraceResult(new Vec3d(0, 0, 0), EnumFacing.UP, pos), 0, ticks); } }
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); } }
@Override public IBitLocation getBitPos( final float hitX, final float hitY, final float hitZ, final EnumFacing side, final BlockPos pos, final boolean placement ) { final RayTraceResult mop = new RayTraceResult( RayTraceResult.Type.BLOCK, new Vec3d( hitX, hitY, hitZ ), side, pos ); return new BitLocation( mop, false, placement ? BitOperation.PLACE : BitOperation.CHISEL ); }
RayTraceResult = new RayTraceResult(entity);
RayTraceResult seacrhForAnomalies(World world) { EnumFacing front = world.getBlockState(getPos()).getValue(MOBlock.PROPERTY_DIRECTION).getOpposite(); for (int i = 1; i < 64; i++) { IBlockState blockState = world.getBlockState(getPos().offset(front, i)); if (blockState.getBlock() instanceof BlockGravitationalAnomaly || blockState.getMaterial().isOpaque()) { return new RayTraceResult(new Vec3d(getPos().offset(front, i)).subtract(Math.abs(front.getDirectionVec().getX() * 0.5), Math.abs(front.getDirectionVec().getY() * 0.5), Math.abs(front.getDirectionVec().getZ() * 0.5)), front.getOpposite(), getPos().offset(front, i)); } } return null; }