Java Code Examples for net.minecraft.world.World.rayTraceBlocks()

The following are Jave code examples for showing how to use rayTraceBlocks() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: Item.java   View Source Code Vote up 6 votes
protected MovingObjectPosition getMovingObjectPositionFromPlayer(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;
    Vec3 vec3 = new Vec3(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;
    Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
    return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false);
}
 
Example 2
Project: DecompiledMinecraft   File: Item.java   View Source Code Vote up 6 votes
protected MovingObjectPosition getMovingObjectPositionFromPlayer(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;
    Vec3 vec3 = new Vec3(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;
    Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
    return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false);
}
 
Example 3
Project: BaseClient   File: Item.java   View Source Code Vote up 6 votes
protected MovingObjectPosition getMovingObjectPositionFromPlayer(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;
    Vec3 vec3 = new Vec3(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;
    Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
    return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false);
}
 
Example 4
Project: BaseClient   File: Item.java   View Source Code Vote up 6 votes
protected MovingObjectPosition getMovingObjectPositionFromPlayer(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;
    Vec3 vec3 = new Vec3(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;
    Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
    return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false);
}
 
Example 5
Project: EndermanEvolution   File: EntityEvolvedEnderman.java   View Source Code Vote up 6 votes
/**
 * Updates the task
 */
@Override
public void updateTask() {
	Random random = enderman.getRNG();
	World world = EasyMappings.world(enderman);
	int i = MathUtils.floor(enderman.posX - 2.0D + random.nextDouble() * 4.0D);
	int j = MathUtils.floor(enderman.posY + random.nextDouble() * 3.0D);
	int k = MathUtils.floor(enderman.posZ - 2.0D + random.nextDouble() * 4.0D);
	BlockPos blockpos = new BlockPos(i, j, k);
	IBlockState iblockstate = world.getBlockState(blockpos);
	Block block = iblockstate.getBlock();
	RayTraceResult raytraceresult = world.rayTraceBlocks(new Vec3d(MathUtils.floor(enderman.posX) + 0.5F, j + 0.5F, MathUtils.floor(enderman.posZ) + 0.5F), new Vec3d(i + 0.5F, j + 0.5F, k + 0.5F), false, true, false);
	boolean flag = raytraceresult != null && raytraceresult.getBlockPos().equals(blockpos);

	if (EntityEvolvedEnderman.getCarriable(block) && flag) {
		enderman.setHeldBlockState(iblockstate);
		world.setBlockToAir(blockpos);
	}
}
 
Example 6
Project: uniquecrops   File: TileShyPlant.java   View Source Code Vote up 6 votes
private RayTraceResult rayTraceFromEntity(World world, Entity player, boolean par3, double range) {
	
	float f = 1.0F;
	float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
	float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
	double d0 = player.prevPosX + (player.posX - player.prevPosX) * f;
	double d1 = player.prevPosY + (player.posY - player.prevPosY) * f;
	if (player instanceof EntityPlayer)
		d1 += ((EntityPlayer)player).eyeHeight;
	double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f;
	Vec3d vec3 = 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;
	double d3 = range;
	Vec3d vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
	return world.rayTraceBlocks(vec3, vec31, par3);
}
 
Example 7
Project: Backmemed   File: EntityEnderman.java   View Source Code Vote up 6 votes
public void updateTask()
{
    Random random = this.enderman.getRNG();
    World world = this.enderman.world;
    int i = MathHelper.floor(this.enderman.posX - 2.0D + random.nextDouble() * 4.0D);
    int j = MathHelper.floor(this.enderman.posY + random.nextDouble() * 3.0D);
    int k = MathHelper.floor(this.enderman.posZ - 2.0D + random.nextDouble() * 4.0D);
    BlockPos blockpos = new BlockPos(i, j, k);
    IBlockState iblockstate = world.getBlockState(blockpos);
    Block block = iblockstate.getBlock();
    RayTraceResult raytraceresult = world.rayTraceBlocks(new Vec3d((double)((float)MathHelper.floor(this.enderman.posX) + 0.5F), (double)((float)j + 0.5F), (double)((float)MathHelper.floor(this.enderman.posZ) + 0.5F)), new Vec3d((double)((float)i + 0.5F), (double)((float)j + 0.5F), (double)((float)k + 0.5F)), false, true, false);
    boolean flag = raytraceresult != null && raytraceresult.getBlockPos().equals(blockpos);

    if (EntityEnderman.CARRIABLE_BLOCKS.contains(block) && flag)
    {
        this.enderman.setHeldBlockState(iblockstate);
        world.setBlockToAir(blockpos);
    }
}
 
Example 8
Project: Backmemed   File: Item.java   View Source Code Vote up 6 votes
protected RayTraceResult rayTrace(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;
    Vec3d vec3d1 = vec3d.addVector((double)f6 * 5.0D, (double)f5 * 5.0D, (double)f7 * 5.0D);
    return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
}
 
Example 9
Project: CustomWorldGen   File: EntityEnderman.java   View Source Code Vote up 6 votes
/**
 * Updates the task
 */
public void updateTask()
{
    Random random = this.enderman.getRNG();
    World world = this.enderman.worldObj;
    int i = MathHelper.floor_double(this.enderman.posX - 2.0D + random.nextDouble() * 4.0D);
    int j = MathHelper.floor_double(this.enderman.posY + random.nextDouble() * 3.0D);
    int k = MathHelper.floor_double(this.enderman.posZ - 2.0D + random.nextDouble() * 4.0D);
    BlockPos blockpos = new BlockPos(i, j, k);
    IBlockState iblockstate = world.getBlockState(blockpos);
    Block block = iblockstate.getBlock();
    RayTraceResult raytraceresult = world.rayTraceBlocks(new Vec3d((double)((float)MathHelper.floor_double(this.enderman.posX) + 0.5F), (double)((float)j + 0.5F), (double)((float)MathHelper.floor_double(this.enderman.posZ) + 0.5F)), new Vec3d((double)((float)i + 0.5F), (double)((float)j + 0.5F), (double)((float)k + 0.5F)), false, true, false);
    boolean flag = raytraceresult != null && raytraceresult.getBlockPos().equals(blockpos);

    if (EntityEnderman.CARRIABLE_BLOCKS.contains(block) && flag)
    {
        this.enderman.setHeldBlockState(iblockstate);
        world.setBlockToAir(blockpos);
    }
}
 
Example 10
Project: CustomWorldGen   File: Item.java   View Source Code Vote up 6 votes
protected RayTraceResult rayTrace(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.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
    return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
}
 
Example 11
Project: pnc-repressurized   File: ModuleAirGrate.java   View Source Code Vote up 5 votes
private void pushEntities(World world, BlockPos pos, Vec3d tileVec) {
    AxisAlignedBB bbBox = new AxisAlignedBB(pos.add(-grateRange, -grateRange, -grateRange), pos.add(grateRange + 1, grateRange + 1, grateRange + 1));
    List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, bbBox, new StringFilterEntitySelector().setFilter(entityFilter));
    double d0 = grateRange + 0.5D;
    for (Entity entity : entities) {
        if (!entity.world.isRemote && entity.getDistanceSq(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) < 0.6D && entity instanceof EntityItem && !entity.isDead) {
            ItemStack leftover = ((EntityItem) entity).getItem();
            for (EnumFacing dir : EnumFacing.VALUES) {
                TileEntity inv = pressureTube.world().getTileEntity(pos.offset(dir));
                leftover = IOHelper.insert(inv, leftover, dir.getOpposite(), false);
                if (leftover.isEmpty()) break;
            }
            if (leftover.isEmpty()) {
                entity.setDead();
            } else {
                ((EntityItem) entity).setItem(leftover);
            }
        } else {
            if (!(entity instanceof EntityPlayer) || !((EntityPlayer) entity).capabilities.isCreativeMode) {
                Vec3d entityVec = new Vec3d(entity.posX, entity.posY, entity.posZ);
                RayTraceResult trace = world.rayTraceBlocks(entityVec, tileVec);
                if (trace != null && trace.getBlockPos().equals(pos)) {
                    double d1 = (entity.posX - pos.getX() - 0.5D) / d0;
                    double d2 = (entity.posY - pos.getY() - 0.5D) / d0;
                    double d3 = (entity.posZ - pos.getZ() - 0.5D) / d0;
                    double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
                    double d5 = 1.0D - d4;

                    if (d5 > 0.0D) {
                        d5 *= d5;
                        if (!vacuum) d5 *= -1;
                        entity.motionX -= d1 / d4 * d5 * 0.1D;
                        entity.motionY -= d2 / d4 * d5 * 0.1D;
                        entity.motionZ -= d3 / d4 * d5 * 0.1D;
                    }
                }
            }
        }
    }
}
 
Example 12
Project: Pangu   File: AIUtils.java   View Source Code Vote up 5 votes
/**
 * checking if two Vec3d can see each other (there are not any block between)
 *
 * the started pos can be likely to:
 *                   for block: new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5)
 *                   for entity: entity.getPositionVector().addVector(0, entity.getEyeHeight(), 0);
 *
 * @return if can see each other
 */
public static boolean canSee(World world, Vec3d traceStart, Vec3d traceEnd) {
    Vec3d vecDelta = new Vec3d(
            traceEnd.x - traceStart.x,
            traceEnd.y - traceStart.y,
            traceEnd.z - traceStart.z
    );

    // Normalize vector to the largest delta axis
    double vecDeltaLength = MathHelper.absMax(vecDelta.x, MathHelper.absMax(vecDelta.y, vecDelta.z));

    vecDelta = vecDelta.scale(1 / vecDeltaLength);

    // Limit how many non solid block a turret can see through
    for (int i = 0; i < 10; i++) {
        // Offset start position toward the target to prevent self collision
        traceStart = traceStart.add(vecDelta);

        RayTraceResult traced = world.rayTraceBlocks(traceStart.add(Vec3d.ZERO), traceEnd.add(Vec3d.ZERO));

        if (traced != null && traced.typeOfHit == RayTraceResult.Type.BLOCK) {
            IBlockState hitBlock = world.getBlockState(traced.getBlockPos());

            // If non solid block is in the way then proceed to continue
            // tracing
            if (hitBlock != null && !hitBlock.getMaterial().isSolid() && MathHelper.absMax(
                    MathHelper.absMax(traceStart.x - traceEnd.x, traceStart.y - traceEnd.y),
                    traceStart.z - traceEnd.z) > 1) {
                // Start at new position and continue
                traceStart = traced.hitVec;
                continue;
            }
        }
        return traced != null;
    }

    // If all above failed, the target cannot be seen
    return false;
}
 
Example 13
Project: Whoosh   File: TeleportUtil.java   View Source Code Vote up 5 votes
public static int getFluidCostBlink(World world, EntityPlayer player, int distance) {

        Vec3d eye = new Vec3d(player.posX, player.posY + player.getEyeHeight(), + player.posZ);
        Vec3d look = player.getLookVec();
        Vec3d end = eye.add(new Vec3d(look.x * distance, look.y * distance, look.z * distance));

        RayTraceResult res = world.rayTraceBlocks(eye, end, false, true, false);
        if(res == null) {
           return 0;
        }
        else {
            return ItemTransporter.teleportFluidBlinkCost;
        }
    }
 
Example 14
Project: Whoosh   File: TeleportUtil.java   View Source Code Vote up 5 votes
public static boolean performBlink(World world, EntityPlayer player, int distance) {

        Vec3d eye = new Vec3d(player.posX, player.posY + player.getEyeHeight() - 0.08, + player.posZ);
        Vec3d look = player.getLookVec();
        Vec3d end = eye.add(new Vec3d(look.x * distance, look.y * distance, look.z * distance));

        RayTraceResult res = world.rayTraceBlocks(eye, end, false, true, false);
        if(res == null) {
            movePlayer(end, player, true);
            return true;
        }
        else {

            List<BlockPos> empty = getBlinkPositions(res, eye, end, distance, world);
            if(empty.size() == 0) {
                return false;
            }

            BlockPos target = empty.get(empty.size() / 2);

            if(target != null) {
                movePlayer(new Vec3d(target.getX() + 0.5, target.getY(), target.getZ() + 0.5), player, false);
                return true;
            }
        }

        return false;
    }
 
Example 15
Project: Mods   File: TF2Util.java   View Source Code Vote up 4 votes
public static float damageBlock(BlockPos pos, EntityLivingBase living, World world, ItemStack stack, int critical, float damage, Vec3d forwardVec, Explosion explosion) {
	IBlockState state = world.getBlockState(pos);
	Block block = state.getBlock();
	if (block.isAir(state, world, pos) || TF2ConfigVars.destTerrain == 0 || state.getBlockHardness(world, pos) < 0 ||
			(!(living instanceof EntityPlayer) && !world.getGameRules().getBoolean("mobGriefing")) || (living instanceof EntityPlayer && !world.isBlockModifiable((EntityPlayer) living, pos)))
		return 0;

	DestroyBlockEntry finalEntry = null;
	int entryId = 0;
	int emptyId = -1;
	for (int i = 0; i < TF2EventsCommon.destroyProgress.size(); i++) {
		DestroyBlockEntry entry = TF2EventsCommon.destroyProgress.get(i);
		if (emptyId == -1 && entry == null)
			emptyId = i;
		if (entry != null && entry.world == world && entry.pos.equals(pos)) {
			finalEntry = entry;
			entryId = i;
			break;
		}
	}
	if (finalEntry == null) {
		finalEntry = new DestroyBlockEntry(pos, world);
		if (emptyId != -1) {
			TF2EventsCommon.destroyProgress.set(emptyId, finalEntry);
			entryId = emptyId;
		} else {
			TF2EventsCommon.destroyProgress.add(finalEntry);
			entryId = TF2EventsCommon.destroyProgress.size() - 1;
		}

	}

	/*if (block instanceof BlockChest) {
		((TileEntityChest) world.getTileEntity(pos)).setLootTable(LootTableList.CHESTS_NETHER_BRIDGE, living.getRNG().nextLong());
	}*/
	float hardness = TF2Util.getHardness(state, world, pos);

	if (!stack.isEmpty() && stack.getItem() instanceof ItemSniperRifle && hardness > 100)
		damage *= 3;
	finalEntry.curDamage += damage;

	if (living != null)
		world.sendBlockBreakProgress(Math.min(Integer.MAX_VALUE, 0xFFFF + entryId), pos, (int) ((finalEntry.curDamage / hardness) * 10));

	if (finalEntry.curDamage >= hardness) {
		if (living != null && living instanceof EntityPlayer)
			block.harvestBlock(world, (EntityPlayer) living, pos, state, null, stack);
		else {
			block.dropBlockAsItem(world, pos, state, 0);
			block.onBlockExploded(world, pos, explosion);
		}
		TF2EventsCommon.destroyProgress.remove(finalEntry);

		boolean flag = (living == null || !(living instanceof EntityPlayer) && world.isAirBlock(pos)) || block.removedByPlayer(state, world, pos, (EntityPlayer) living, true);

		if (flag) {
			if (living != null) {
				world.playEvent(2001, pos, Block.getStateId(state));
				world.sendBlockBreakProgress(Math.min(Integer.MAX_VALUE, 0xFFFF + entryId), pos, -1);
			}
			block.onBlockDestroyedByPlayer(world, pos, state);

			if (forwardVec != null) {
				RayTraceResult trace = world.rayTraceBlocks(living.getPositionVector().addVector(0, living.getEyeHeight(), 0), forwardVec, false, true, false);
				if (trace != null)
					damageBlock(trace.getBlockPos(), living, world, stack, critical, finalEntry.curDamage - hardness, forwardVec, explosion);
			}
		}
		return finalEntry.curDamage - hardness;
	}
	return 0;
}
 
Example 16
Project: SimpleTractor   File: ItemTractor.java   View Source Code Vote up 4 votes
@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);
            }
        }
    }
}