Java Code Examples for net.minecraft.entity.player.EntityPlayer.getDistanceSq()

The following are Jave code examples for showing how to use getDistanceSq() of the net.minecraft.entity.player.EntityPlayer 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: BaseClient   File: WorldServer.java   View Source Code Vote up 6 votes
/**
 * returns a new explosion. Does initiation (at time of writing Explosion is not finished)
 */
public Explosion newExplosion(Entity entityIn, double x, double y, double z, float strength, boolean isFlaming, boolean isSmoking)
{
    Explosion explosion = new Explosion(this, entityIn, x, y, z, strength, isFlaming, isSmoking);
    explosion.doExplosionA();
    explosion.doExplosionB(false);

    if (!isSmoking)
    {
        explosion.func_180342_d();
    }

    for (EntityPlayer entityplayer : this.playerEntities)
    {
        if (entityplayer.getDistanceSq(x, y, z) < 4096.0D)
        {
            ((EntityPlayerMP)entityplayer).playerNetServerHandler.sendPacket(new S27PacketExplosion(x, y, z, strength, explosion.getAffectedBlockPositions(), (Vec3)explosion.getPlayerKnockbackMap().get(entityplayer)));
        }
    }

    return explosion;
}
 
Example 2
Project: Backmemed   File: World.java   View Source Code Vote up 6 votes
public boolean isAnyPlayerWithinRangeAt(double x, double y, double z, double range)
{
    for (int i = 0; i < this.playerEntities.size(); ++i)
    {
        EntityPlayer entityplayer = (EntityPlayer)this.playerEntities.get(i);

        if (EntitySelectors.NOT_SPECTATING.apply(entityplayer))
        {
            double d0 = entityplayer.getDistanceSq(x, y, z);

            if (range < 0.0D || d0 < range * range)
            {
                return true;
            }
        }
    }

    return false;
}
 
Example 3
Project: DecompiledMinecraft   File: World.java   View Source Code Vote up 5 votes
protected void playMoodSoundAndCheckLight(int p_147467_1_, int p_147467_2_, Chunk chunkIn)
{
    this.theProfiler.endStartSection("moodSound");

    if (this.ambientTickCountdown == 0 && !this.isRemote)
    {
        this.updateLCG = this.updateLCG * 3 + 1013904223;
        int i = this.updateLCG >> 2;
        int j = i & 15;
        int k = i >> 8 & 15;
        int l = i >> 16 & 255;
        BlockPos blockpos = new BlockPos(j, l, k);
        Block block = chunkIn.getBlock(blockpos);
        j = j + p_147467_1_;
        k = k + p_147467_2_;

        if (block.getMaterial() == Material.air && this.getLight(blockpos) <= this.rand.nextInt(8) && this.getLightFor(EnumSkyBlock.SKY, blockpos) <= 0)
        {
            EntityPlayer entityplayer = this.getClosestPlayer((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, 8.0D);

            if (entityplayer != null && entityplayer.getDistanceSq((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D) > 4.0D)
            {
                this.playSoundEffect((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, "ambient.cave.cave", 0.7F, 0.8F + this.rand.nextFloat() * 0.2F);
                this.ambientTickCountdown = this.rand.nextInt(12000) + 6000;
            }
        }
    }

    this.theProfiler.endStartSection("checkLight");
    chunkIn.enqueueRelightChecks();
}
 
Example 4
Project: rezolve   File: MachineEntity.java   View Source Code Vote up 4 votes
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
	return this.worldObj.getTileEntity(this.getPos()) == this
			&& player.getDistanceSq(this.pos.add(0.5, 0.5, 0.5)) <= 64;
}
 
Example 5
Project: Backmemed   File: World.java   View Source Code Vote up 4 votes
@Nullable
public EntityPlayer getNearestAttackablePlayer(double posX, double posY, double posZ, double maxXZDistance, double maxYDistance, @Nullable Function<EntityPlayer, Double> playerToDouble, @Nullable Predicate<EntityPlayer> p_184150_12_)
{
    double d0 = -1.0D;
    EntityPlayer entityplayer = null;

    for (int i = 0; i < this.playerEntities.size(); ++i)
    {
        EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);

        if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive() && !entityplayer1.isSpectator() && (p_184150_12_ == null || p_184150_12_.apply(entityplayer1)))
        {
            double d1 = entityplayer1.getDistanceSq(posX, entityplayer1.posY, posZ);
            double d2 = maxXZDistance;

            if (entityplayer1.isSneaking())
            {
                d2 = maxXZDistance * 0.800000011920929D;
            }

            if (entityplayer1.isInvisible())
            {
                float f = entityplayer1.getArmorVisibility();

                if (f < 0.1F)
                {
                    f = 0.1F;
                }

                d2 *= (double)(0.7F * f);
            }

            if (playerToDouble != null)
            {
                d2 *= ((Double)Objects.firstNonNull(playerToDouble.apply(entityplayer1), Double.valueOf(1.0D))).doubleValue();
            }

            if ((maxYDistance < 0.0D || Math.abs(entityplayer1.posY - posY) < maxYDistance * maxYDistance) && (maxXZDistance < 0.0D || d1 < d2 * d2) && (d0 == -1.0D || d1 < d0))
            {
                d0 = d1;
                entityplayer = entityplayer1;
            }
        }
    }

    return entityplayer;
}
 
Example 6
Project: connor41-etfuturum2   File: ContainerEnchantment.java   View Source Code Vote up 4 votes
@Override
public boolean canInteractWith(EntityPlayer player) {
	return world.getBlock(posX, posY, posZ) != ModBlocks.enchantment_table ? false : player.getDistanceSq(posX + 0.5D, posY + 0.5D, posZ + 0.5D) <= 64.0D;
}
 
Example 7
Project: pnc-repressurized   File: TileEntityPressureChamberInterface.java   View Source Code Vote up 4 votes
@Override
public boolean isGuiUseableByPlayer(EntityPlayer player) {
    return getWorld().getTileEntity(getPos()) == this
            && player.getDistanceSq(getPos().getX() + 0.5D, getPos().getY() + 0.5D, getPos().getZ() + 0.5D) <= 64.0D;
}
 
Example 8
Project: DecompiledMinecraft   File: ContainerWorkbench.java   View Source Code Vote up 4 votes
public boolean canInteractWith(EntityPlayer playerIn)
{
    return this.worldObj.getBlockState(this.pos).getBlock() != Blocks.crafting_table ? false : playerIn.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
}
 
Example 9
Project: PurificatiMagicae   File: ContainerCodeStorage.java   View Source Code Vote up 4 votes
@Override
public boolean canInteractWith(EntityPlayer playerIn)
{
    return playerIn.getDistanceSq(storage.getPos()) < 64;
}
 
Example 10
Project: DecompiledMinecraft   File: ContainerWorkbench.java   View Source Code Vote up 4 votes
public boolean canInteractWith(EntityPlayer playerIn)
{
    return this.worldObj.getBlockState(this.pos).getBlock() != Blocks.crafting_table ? false : playerIn.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
}
 
Example 11
Project: FundamentalChemistry   File: TileSimpleMachine.java   View Source Code Vote up 4 votes
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
   return this.worldObj.getTileEntity(this.getPos()) == this && player.getDistanceSq(this.pos.add(0.5, 0.5, 0.5)) <= 64;
}
 
Example 12
Project: CustomWorldGen   File: TileEntityHopper.java   View Source Code Vote up 4 votes
/**
 * Don't rename this method to canInteractWith due to conflicts with Container
 */
public boolean isUseableByPlayer(EntityPlayer player)
{
    return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
}
 
Example 13
Project: MiningWells   File: TileEntityMiningWell.java   View Source Code Vote up 4 votes
public boolean isUsableByPlayer(EntityPlayer player) {
	return player.getDistanceSq(pos.add(0.5f, 0.5f, 0.5f)) <= 64;
}
 
Example 14
Project: MagicWinds   File: TileEntityTrinketMaker.java   View Source Code Vote up 4 votes
@Override
public boolean isUsableByPlayer(EntityPlayer player) {
    return this.world.getTileEntity(this.getPos()) == this && player.getDistanceSq(this.pos.add(0.5,0.5,0.5)) <= 64;
}
 
Example 15
Project: Defier   File: PatternMolderContainer.java   View Source Code Vote up 4 votes
@Override
public boolean canInteractWith(EntityPlayer playerIn) {
	return !te.isInvalid() && playerIn.getDistanceSq(te.getPos().add(0.5D, 0.5D, 0.5D)) <= 64D;
}
 
Example 16
Project: VanillaExtras   File: TileEntityBlockBreaker.java   View Source Code Vote up 4 votes
public boolean isUseableByPlayer(EntityPlayer player) {
	return this.world.getTileEntity(this.getPos()) == this
			&& player.getDistanceSq(this.pos.add(0.5, 0.5, 0.5)) <= 64;
}
 
Example 17
Project: BaseClient   File: ContainerRepair.java   View Source Code Vote up 4 votes
public boolean canInteractWith(EntityPlayer playerIn)
{
    return this.theWorld.getBlockState(this.selfPosition).getBlock() != Blocks.anvil ? false : playerIn.getDistanceSq((double)this.selfPosition.getX() + 0.5D, (double)this.selfPosition.getY() + 0.5D, (double)this.selfPosition.getZ() + 0.5D) <= 64.0D;
}
 
Example 18
Project: CustomWorldGen   File: ContainerRepair.java   View Source Code Vote up 4 votes
/**
 * Determines whether supplied player can use this container
 */
public boolean canInteractWith(EntityPlayer playerIn)
{
    return this.theWorld.getBlockState(this.selfPosition).getBlock() != Blocks.ANVIL ? false : playerIn.getDistanceSq((double)this.selfPosition.getX() + 0.5D, (double)this.selfPosition.getY() + 0.5D, (double)this.selfPosition.getZ() + 0.5D) <= 64.0D;
}
 
Example 19
Project: DecompiledMinecraft   File: TileEntityDispenser.java   View Source Code Vote up 4 votes
/**
 * Do not make give this method the name canInteractWith because it clashes with Container
 */
public boolean isUseableByPlayer(EntityPlayer player)
{
    return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
}
 
Example 20
Project: BaseClient   File: TileEntityBeacon.java   View Source Code Vote up 4 votes
/**
 * Do not make give this method the name canInteractWith because it clashes with Container
 */
public boolean isUseableByPlayer(EntityPlayer player)
{
    return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
}