Java Code Examples for net.minecraft.world.World#getPlayerEntityByUUID()

The following examples show how to use net.minecraft.world.World#getPlayerEntityByUUID() . 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
Source File: ItemSyringe.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
	String desc = stack.getTranslationKey() + ".desc";
	String used = LibrarianLib.PROXY.canTranslate(desc) ? desc : desc + "0";
	if (LibrarianLib.PROXY.canTranslate(used)) {
		TooltipHelper.addToTooltip(tooltip, used);
		int i = 0;
		while (LibrarianLib.PROXY.canTranslate(desc + (++i)))
			TooltipHelper.addToTooltip(tooltip, desc + i);
	}

	if (stack.getItemDamage() == 3 && stack.hasTagCompound()) {
		UUID uuid = NBTHelper.getUniqueId(stack, "uuid");
		String entity = NBTHelper.getString(stack, "entity");
		if (uuid != null) {
			EntityPlayer player1 = null;
			if (worldIn != null) {
				player1 = worldIn.getPlayerEntityByUUID(uuid);
			}
			if (player1 != null) tooltip.add(player1.getName());
		}
		if (entity != null) {
			tooltip.add(entity);
		}
	}
}
 
Example 2
Source File: MessageCompareLight.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
protected void processMessage(MessageContext ctx) {
    // Get world.
    final World world = AgriCraft.proxy.getWorldByDimensionId(this.dimId);
    
    // Get player.
    final EntityPlayer player = world.getPlayerEntityByUUID(UUID.fromString(this.playerId));
    
    // Get server light data.
    final byte serverLightData[] = LightHelper.getLightData(world, this.pos);
    
    // Message the light data to the player.
    LightHelper.messageLightData(player, clientLightData, serverLightData);
}
 
Example 3
Source File: ItemMobHarness.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private boolean mountTarget(ItemStack stack, World world, EntityPlayer player, Entity targetEntity)
{
    if (stack.getTagCompound() == null || targetEntity == null)
    {
        return false;
    }

    NBTTagCompound nbt = stack.getTagCompound();
    byte mode = nbt.getByte("Mode");
    UUID storedUUID = new UUID(nbt.getLong("TargetUUIDMost"), nbt.getLong("TargetUUIDLeast"));
    Entity storedEntity = null;
    double r = 64.0d;

    // The harness was clicked twice on the same entity, mount that entity on top of the player
    if (storedUUID.equals(targetEntity.getUniqueID()))
    {
        EntityUtils.unmountFirstRider(player);
        targetEntity.startRiding(player, true);
        this.clearData(stack);

        return true;
    }
    // The harness was clicked on two separate entities, mount the stored/first one on top of the currently targeted one
    else
    {
        // Mode 1: mount non-player entities to each other or to the player
        if (mode == 1)
        {
            List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(player,
                    new AxisAlignedBB(player.posX - r, player.posY - r, player.posZ - r,
                            player.posX + r, player.posY + r, player.posZ + r));
            storedEntity = EntityUtils.findEntityByUUID(entities, storedUUID);
        }
        // Mode 2: mount a player
        else if (mode == 2)
        {
            storedEntity = world.getPlayerEntityByUUID(storedUUID);
        }

        // Matching (stored) entity found
        if (storedEntity != null && storedEntity.dimension == player.dimension)
        {
            // Don't allow mounting the entity into the same stack, or nasty infinite loops will happen >_>
            if (EntityUtils.doesEntityStackContainEntity(storedEntity, targetEntity) == false)
            {
                //EntityUtils.unmountFirstRider(targetEntity);
                storedEntity.startRiding(targetEntity, true);
                this.clearData(stack);
                return true;
            }
        }
        else if (storedEntity == null && world.isRemote == false)
        {
            player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.mobharness.targetnotfoundoroutofrange"), true);
        }
    }

    return false;
}