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

The following examples show how to use net.minecraft.entity.player.EntityPlayer#getDistanceSq() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private boolean isStackedAreaWithinLimits(BlockPos pos1, BlockPos pos2, BlockPos endPosRelative, Area3D area, EntityPlayer player)
{
    int sx = Math.abs(endPosRelative.getX()) + 1;
    int sy = Math.abs(endPosRelative.getY()) + 1;
    int sz = Math.abs(endPosRelative.getZ()) + 1;
    BlockPos posMin = PositionUtils.getMinCorner(pos1, pos2).add(-area.getXNeg() * sx, -area.getYNeg() * sy, -area.getZNeg() * sz);
    BlockPos posMax = PositionUtils.getMaxCorner(pos1, pos2).add( area.getXPos() * sx,  area.getYPos() * sy,  area.getZPos() * sz);
    int max = 160;

    if (player.getDistanceSq(posMin) > (max * max) || player.getDistanceSq(posMax) > (max * max))
    {
        return false;
    }

    return true;
}
 
Example 2
@Override
public boolean isUsableByPlayer(EntityPlayer entityPlayer) {
    if (this.world.getTileEntity(this.pos) != this) {
        return false;
    } else {
        return entityPlayer.getDistanceSq((double) this.pos.getX() + 0.5D, (double) this.pos.getY() + 0.5D, (double) this.pos.getZ() + 0.5D) <= 64.0D;
    }
}
 
Example 3
public boolean isUsableByPlayer(EntityPlayer player) {
    if (this.world.getTileEntity(this.pos) != this) {
        return false;
    } else {
        return player
            .getDistanceSq((double) this.pos.getX() + 0.5D, (double) this.pos.getY() + 0.5D,
                (double) this.pos.getZ() + 0.5D) <= 64.0D;
    }
}
 
Example 4
Source Project: GardenCollection   File: TileEntityGarden.java    License: MIT License 5 votes vote down vote up
@Override
public boolean isUseableByPlayer (EntityPlayer player) {
    if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
        return false;

    return player.getDistanceSq(xCoord + .5, yCoord + .5, zCoord + .5) <= 64;
}
 
Example 5
Source Project: Sakura_mod   File: TileEntityBarrel.java    License: MIT License 5 votes vote down vote up
@Override
public boolean isUsableByPlayer(EntityPlayer player) {
	if (this.world.getTileEntity(this.pos) != this) {
		return false;
	}
	return player.getDistanceSq(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D) <= 64.0D;
}
 
Example 6
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
	if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
	{
		return false;
	}
	return entityplayer.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64D;
}
 
Example 7
Source Project: Et-Futurum   File: ContainerAnvil.java    License: The Unlicense 4 votes vote down vote up
@Override
public boolean canInteractWith(EntityPlayer player) {
	return world.getBlock(x, y, z) != ModBlocks.anvil ? false : player.getDistanceSq(x + 0.5D, y + 0.5D, z + 0.5D) <= 64.0D;
}
 
Example 8
@Override
public boolean isUseableByPlayer (EntityPlayer player) {
    return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + .5, yCoord + .5, zCoord + .5) <= 64;
}
 
Example 9
Source Project: AdvancedRocketry   File: TileDataProgrammer.java    License: MIT License 4 votes vote down vote up
@Override
public boolean isUsableByPlayer(EntityPlayer player) {
	return player.getDistanceSq(pos) < 4096;
}
 
Example 10
Source Project: archimedes-ships   File: TileEntityEngine.java    License: MIT License 4 votes vote down vote up
@Override
public boolean isUseableByPlayer(EntityPlayer player)
{
	return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5d, yCoord + 0.5d, zCoord + 0.5d) <= 64d;
}
 
Example 11
Source Project: Production-Line   File: TileContainer.java    License: MIT License 4 votes vote down vote up
@Override
public boolean isUsableByPlayer(EntityPlayer entityPlayer) {
    return !this.isInvalid() && entityPlayer.getDistanceSq(pos) <= 4096;
}
 
Example 12
private void deleteArea(ItemStack stack, World world, EntityPlayer player, BlockPos posStart, BlockPos posEnd, boolean removeEntities)
{
    if (posStart == null || posEnd == null)
    {
        return;
    }

    if (player.getDistanceSq(posStart) > 160 * 160)
    {
        player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.areatoofar"), true);
        return;
    }

    if (this.isAreaWithinSizeLimit(posStart.subtract(posEnd), stack, player) == false)
    {
        player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.areatoolarge"), true);
        return;
    }

    // Set all blocks to air
    for (BlockPos.MutableBlockPos posMutable : BlockPos.getAllInBoxMutable(posStart, posEnd))
    {
        if (world.isAirBlock(posMutable) == false)
        {
            BlockUtils.setBlockToAirWithoutSpillingContents(world, posMutable, 2);
        }
    }

    // Remove pending block updates from within the area
    BlockPos posMin = PositionUtils.getMinCorner(posStart, posEnd);
    BlockPos posMax = PositionUtils.getMaxCorner(posStart, posEnd).add(1, 1, 1);
    StructureBoundingBox sbb = StructureBoundingBox.createProper(posMin.getX(), posMin.getY(), posMin.getZ(), posMax.getX(), posMax.getY(), posMax.getZ());
    world.getPendingBlockUpdates(sbb, true); // The boolean parameter indicates whether the entries will be removed

    // Remove all entities within the area
    int count = 0;

    if (removeEntities)
    {
        int x1 = Math.min(posStart.getX(), posEnd.getX());
        int y1 = Math.min(posStart.getY(), posEnd.getY());
        int z1 = Math.min(posStart.getZ(), posEnd.getZ());
        int x2 = Math.max(posStart.getX(), posEnd.getX());
        int y2 = Math.max(posStart.getY(), posEnd.getY());
        int z2 = Math.max(posStart.getZ(), posEnd.getZ());

        AxisAlignedBB bb = new AxisAlignedBB(x1, y1, z1, x2 + 1, y2 + 1, z2 + 1);
        List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, bb);

        for (Entity entity : entities)
        {
            if ((entity instanceof EntityPlayer) == false || entity instanceof FakePlayer)
            {
                entity.setDead();
                count++;
            }
        }

        if (count > 0)
        {
            player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.killedentitieswithcount", count), true);
        }
    }
}
 
Example 13
@Override
public boolean isUsableByPlayer(EntityPlayer player) {
	return player.getDistanceSq(pos) < 4096;
}
 
Example 14
Source Project: Cyberware   File: TileEntityComponentBox.java    License: MIT License 4 votes vote down vote up
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 15
@Override
public boolean isGuiUseableByPlayer(EntityPlayer par1EntityPlayer){
    return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : par1EntityPlayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64.0D;
}
 
Example 16
public boolean isGuiUseableByPlayer(EntityPlayer par1EntityPlayer){
    return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : par1EntityPlayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64.0D;
}
 
Example 17
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) {
    return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D;
}
 
Example 18
Source Project: Cyberware   File: TileEntityEngineeringTable.java    License: MIT License 4 votes vote down vote up
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 19
Source Project: AdvancedRocketry   File: TileSatelliteBuilder.java    License: MIT License 4 votes vote down vote up
@Override
public boolean isUsableByPlayer(EntityPlayer player) {
	return player.getDistanceSq(pos) < 4192;
}
 
Example 20
@Override
public boolean isUsableByPlayer(EntityPlayer entityPlayer) {
    if (this.world.getTileEntity(this.pos) != this) {

        return false;

    } else {

        return entityPlayer.getDistanceSq((double) this.pos.getX() + 0.5D, (double) this.pos.getY() + 0.5D, (double) this.pos.getZ() + 0.5D) <= 64.0D;

    }
}