Java Code Examples for net.minecraft.entity.EntityLivingBase#getUniqueID()

The following examples show how to use net.minecraft.entity.EntityLivingBase#getUniqueID() . 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 check out the related API usage on the sidebar.
Example 1
private void signContract(ItemStack stack, EntityPlayer oldOwner, EntityLivingBase target)
{
    NBTTagCompound nbt = NBTUtils.getCompoundTag(stack, null, true);
    UUID uuidOwner = oldOwner.getUniqueID();
    nbt.setLong("OwnerM", uuidOwner.getMostSignificantBits());
    nbt.setLong("OwnerL", uuidOwner.getLeastSignificantBits());

    UUID uuidTarget = target.getUniqueID();
    nbt.setLong("OwnableM", uuidTarget.getMostSignificantBits());
    nbt.setLong("OwnableL", uuidTarget.getLeastSignificantBits());

    nbt.setFloat("Health", target.getHealth());
    String str = EntityList.getEntityString(target);

    if (str != null)
    {
        nbt.setString("EntityString", str);
    }

    if (target.hasCustomName())
    {
        nbt.setString("CustomName", target.getCustomNameTag());
    }

    oldOwner.getEntityWorld().playSound(null, oldOwner.getPosition(), SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.PLAYERS, 0.5f, 1f);
}
 
Example 2
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer,
		ItemStack stack) {
	super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
	TileEntity tile = worldIn.getTileEntity(pos);
	if (tile instanceof IOwnerBlock && placer != null) {
		UUID owner = placer.getUniqueID();
		((IOwnerBlock) tile).setOwner(owner);
	}
}
 
Example 3
public void setOwner(EntityLivingBase placer) {
	UUID user = placer.getUniqueID();
	String name = placer.getName();
	if (this.owner == null && user != null) {
		this.owner = user;
		this.ownerName = name;
		this.getNetwork().updateTileGuiField(this, "ownerName");
	}
}
 
Example 4
public EntityEnderArrow(World worldIn, EntityLivingBase shooter, EntityLivingBase par3EntityLivingBase, float par4, float par5)
{
    super(worldIn);
    this.shootingEntity = shooter;
    this.shooterUUID = shooter.getUniqueID();

    if (shooter instanceof EntityPlayer)
    {
        this.canBePickedUp = 1;

        if (((EntityPlayer)shooter).capabilities.isCreativeMode)
        {
            this.canBePickedUp = 2;
        }
    }

    this.posY = shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D;
    double d0 = par3EntityLivingBase.posX - shooter.posX;
    double d1 = par3EntityLivingBase.getEntityBoundingBox().minY + (double)(par3EntityLivingBase.height / 3.0F) - this.posY;
    double d2 = par3EntityLivingBase.posZ - shooter.posZ;
    double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);

    if (d3 >= 1.0E-7D)
    {
        float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
        float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI));
        double d4 = d0 / d3;
        double d5 = d2 / d3;
        this.setLocationAndAngles(shooter.posX + d4, this.posY, shooter.posZ + d5, f2, f3);
        float f4 = (float)d3 * 0.2F;
        this.shoot(d0, d1 + (double)f4, d2, par4, par5);
    }
}
 
Example 5
public EntityEnderArrow(World worldIn, EntityLivingBase shooter, float velocity)
{
    super(worldIn);
    this.shootingEntity = shooter;
    this.shooterUUID = shooter.getUniqueID();

    if (shooter instanceof EntityPlayer)
    {
        this.canBePickedUp = 1;

        if (((EntityPlayer)shooter).capabilities.isCreativeMode)
        {
            this.canBePickedUp = 2;
        }
    }

    this.setSize(0.5F, 0.5F);
    this.setLocationAndAngles(shooter.posX, shooter.posY + (double)shooter.getEyeHeight(), shooter.posZ, shooter.rotationYaw, shooter.rotationPitch);
    double x, y, z;
    x = this.posX - (double)(MathHelper.cos(this.rotationYaw / 180.0f * (float)Math.PI) * 0.16f);
    z = this.posZ - (double)(MathHelper.sin(this.rotationYaw / 180.0f * (float)Math.PI) * 0.16f);

    x -= (double)(MathHelper.sin(this.rotationYaw / 180.0f * (float)Math.PI) * 0.74f) * (double)(MathHelper.cos(this.rotationPitch / 180.0f * (float)Math.PI));
    x -= (double)(MathHelper.cos(this.rotationYaw / 180.0f * (float)Math.PI) * 0.1f);
    y = this.posY - 0.10000000149011612d;
    z += (double)(MathHelper.cos(this.rotationYaw / 180.0f * (float)Math.PI) * 0.74f) * (double)(MathHelper.cos(this.rotationPitch / 180.0f * (float)Math.PI));
    z -= (double)(MathHelper.sin(this.rotationYaw / 180.0f * (float)Math.PI) * 0.1f);
    if (worldIn.isAirBlock(new BlockPos((int)MathHelper.floor(x), (int)y, (int)MathHelper.floor(z))))
    {
        this.posX = x;
        this.posZ = z;
    }
    this.setPosition(this.posX, this.posY, this.posZ);
    this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
    this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
    this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
    this.shoot(this.motionX, this.motionY, this.motionZ, velocity * 1.8F, 1.0F);
}
 
Example 6
public void setAssignedTarget(@Nullable EntityLivingBase target)
{
    this.assignedTarget = target;

    if (target != null)
    {
        this.assignedTargetUUID = target.getUniqueID();
    }
    else
    {
        this.assignedTargetUUID = null;
    }
}
 
Example 7
@Override
public void setRevengeTarget(@Nullable EntityLivingBase target)
{
    this.revengeTarget = target;

    if (target != null)
    {
        this.revengeTargetUUID = target.getUniqueID();
    }
    else
    {
        this.revengeTargetUUID = null;
    }
}
 
Example 8
public void setThrower(EntityLivingBase entity)
{
    this.throwerUUID = entity.getUniqueID();
}