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

The following examples show how to use net.minecraft.entity.player.EntityPlayer#getUniqueID() . 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: ModGenuinePeoplePersonalities.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static boolean testCooldown(EntityPlayer player) {
    UUID uuid = player.getUniqueID();
    int cooldown;
    if (cooldownMap.containsKey(uuid)) {
        cooldown = cooldownMap.getInt(uuid);
    } else {
        cooldown = 0;
    }

    if (cooldown - player.ticksExisted < 0) {
        cooldown = player.ticksExisted - 1;
    }

    if (cooldown > player.ticksExisted) {
        CommunityMod.LOGGER.info(((cooldown - player.ticksExisted) / 20) + " seconds until next event.");
        return false;
    }

    return true;
}
 
Example 2
Source File: ItemPetContract.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 3
Source File: PlayerTaskScheduler.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void addTask(EntityPlayer player, IPlayerTask task, int interval)
{
    task.init();

    UUID uuid = player.getUniqueID();
    List<IPlayerTask> playerTasks = this.tasks.get(uuid);
    List<Timer> timers = this.timers.get(uuid);

    if (playerTasks == null)
    {
        playerTasks = new ArrayList<IPlayerTask>();
        timers = new ArrayList<Timer>();
        this.tasks.put(uuid, playerTasks);
        this.timers.put(uuid, timers);
    }

    playerTasks.add(task);
    timers.add(new Timer(interval));
}
 
Example 4
Source File: PurchaseApi.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public UUID nameToUUID(String name) {
    UUID uuid = nameToUuid.get(name.toLowerCase());
    if (uuid != null) return uuid;
    WorldClient theWorld = Minecraft.getMinecraft().theWorld;
    if (theWorld == null) return null;

    for (EntityPlayer playerEntity : theWorld.playerEntities) {
        if (playerEntity.getName().equalsIgnoreCase(name) || EnumChatFormatting.getTextWithoutFormattingCodes(playerEntity.getName()).equalsIgnoreCase(name)) {
            nameToUuid.put(name.toLowerCase(), playerEntity.getUniqueID());
            return playerEntity.getUniqueID();
        }
    }

    return null;
}
 
Example 5
Source File: TileEntityPilotableImpl.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public final void setPilotEntity(EntityPlayer toSet) {
    if (!getWorld().isRemote) {
        EntityPlayer oldPlayer = getPilotEntity();
        sendPilotUpdatePackets((EntityPlayerMP) toSet, (EntityPlayerMP) oldPlayer);
    }
    if (toSet != null) {
        pilotPlayerEntity = toSet.getUniqueID();
        onStartTileUsage();
    } else {
        pilotPlayerEntity = null;
        onStopTileUsage();
    }
}
 
Example 6
Source File: CustomDropsHandler.java    From NewHorizonsCoreMod with GNU General Public License v3.0 5 votes vote down vote up
public void toggleDeathInfoForPlayer(EntityPlayer pEP)
{
    UUID tUUID = pEP.getUniqueID();
    if (_mDeathDebugPlayers.contains(tUUID))
    {
        _mDeathDebugPlayers.remove(tUUID);
        PlayerChatHelper.SendInfo(pEP, "Death-Debug is now diabled");
    }
    else
    {
        _mDeathDebugPlayers.add(tUUID);
        PlayerChatHelper.SendInfo(pEP, "Death-Debug is now enabled");
    }
}
 
Example 7
Source File: InventoryItemPermissions.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public InventoryItemPermissions(ItemStack containerStack, int invSize, int stackLimit, boolean allowCustomStackSizes,
        boolean isRemote, EntityPlayer player, String tagName, UUID containerUUID, IItemHandler hostInv)
{
    super(containerStack, invSize, stackLimit, allowCustomStackSizes, isRemote, tagName,containerUUID, hostInv);

    if (player != null)
    {
        this.accessorUUID = player.getUniqueID();
    }
}
 
Example 8
Source File: ItemBuildersWand.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private EnumActionResult pasteAreaIntoWorld(ItemStack stack, World world, EntityPlayer player, BlockPosEU posStartIn)
{
    if (posStartIn == null)
    {
        return EnumActionResult.FAIL;
    }

    if (player.capabilities.isCreativeMode == false && Configs.buildersWandEnablePasteMode == false)
    {
        player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.featuredisabledinsurvivalmode"), true);
        return EnumActionResult.FAIL;
    }

    if (posStartIn.isWithinDistance(player, 160) == false)
    {
        player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.areatoofar"), true);
        return EnumActionResult.FAIL;
    }

    TemplateMetadata templateMeta = this.getTemplateMetadata(stack, player);

    if (this.isAreaWithinSizeLimit(templateMeta.getRelativeEndPosition(), stack, player) == false)
    {
        player.sendStatusMessage(new TextComponentTranslation("enderutilities.chat.message.areatoolarge", this.getMaxAreaDimension(stack, player)), true);
        return EnumActionResult.FAIL;
    }

    PlacementSettings placement = this.getPasteModePlacement(stack, player);
    TemplateEnderUtilities template = this.getTemplate(world, player, stack, placement);

    if (player.capabilities.isCreativeMode)
    {
        template.setReplaceMode(WandOption.REPLACE_EXISTING.isEnabled(stack, Mode.PASTE) ? ReplaceMode.EVERYTHING : ReplaceMode.NOTHING);
        template.addBlocksToWorld(world, posStartIn.toBlockPos());
    }
    else
    {
        template.setReplaceMode(WandOption.REPLACE_EXISTING.isEnabled(stack, Mode.PASTE) ? ReplaceMode.WITH_NON_AIR : ReplaceMode.NOTHING);

        UUID wandUUID = NBTUtils.getUUIDFromItemStack(stack, WRAPPER_TAG_NAME, true);
        TaskTemplatePlaceBlocks task = new TaskTemplatePlaceBlocks(template, posStartIn.toBlockPos(), world.provider.getDimension(),
                player.getUniqueID(), wandUUID, Configs.buildersWandBlocksPerTick);
        PlayerTaskScheduler.getInstance().addTask(player, task, 1);
    }

    return EnumActionResult.SUCCESS;
}
 
Example 9
Source File: RenderEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private List<String> getPlacementPropertiesText(ItemBlockPlacementProperty item, ItemStack stack, EntityPlayer player)
{
    String preGreen = TextFormatting.GREEN.toString();
    String rst = TextFormatting.RESET.toString() + TextFormatting.WHITE.toString();

    List<String> lines = new ArrayList<String>();
    PlacementProperties props = PlacementProperties.getInstance();
    UUID uuid = player.getUniqueID();
    PlacementProperty pp = item.getPlacementProperty(stack);
    boolean nbtSensitive = pp.isNBTSensitive();
    ItemType type = new ItemType(stack, nbtSensitive);
    int index = props.getPropertyIndex(uuid, type);
    int count = pp.getPropertyCount();

    for (int i = 0; i < count; i++)
    {
        Pair<String, Integer> pair = pp.getProperty(i);

        if (pair != null)
        {
            String key = pair.getLeft();
            String pre = (i == index) ? "> " : "  ";
            String name = I18n.format("enderutilities.placement_properties." + key);
            int value = props.getPropertyValue(uuid, type, key, pair.getRight());
            String valueName = pp.getPropertyValueName(key, value);

            if (valueName == null)
            {
                valueName = String.valueOf(value);
            }
            else
            {
                valueName = I18n.format("enderutilities.placement_properties.valuenames." + key + "." + valueName);
            }

            lines.add(String.format("%s%s: %s%s%s", pre, name, preGreen, valueName, rst));
        }
    }

    return lines;
}
 
Example 10
Source File: TileEntityDisplayPedestal.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
	boolean sendNamePacket = false;
	
	if(entityplayer.worldObj.isRemote) {
		return false;
	}
	
	if( (ownerName == null || ownerName.equals("")) && (ownerUUID == null || ownerUUID.equals(new UUID(0, 0))) ) {
		ownerName = entityplayer.getCommandSenderName();
		ownerUUID = entityplayer.getUniqueID();
		this.markDirty();
		sendNamePacket = true;
	}
	
	if(ownerName.equals(entityplayer.getCommandSenderName()) && (ownerName == null || !ownerUUID.equals(entityplayer.getUniqueID()))) {
		ownerUUID = entityplayer.getUniqueID();
		this.markDirty();
	}
	
	if((ownerName == null || !ownerName.equals(entityplayer.getCommandSenderName())) && ownerUUID.equals(entityplayer.getUniqueID())) {
		ownerName = entityplayer.getCommandSenderName();
		this.markDirty();
		sendNamePacket = true;
	}
	
	if(sendNamePacket) {
		PacketBuffer out = new PacketBuffer(Unpooled.buffer());
		out.writeInt(PacketHandlerClient.PEDESTAL);
		out.writeInt(xCoord);
		out.writeInt(yCoord);
		out.writeInt(zCoord);
		out.writeInt(ownerName.length());
		for(int i = 0; i < ownerName.length(); i++) {
			out.writeChar(ownerName.charAt(i));
		}
		SToCMessage namePacket = new SToCMessage(out);
		DragonArtifacts.artifactNetworkWrapper.sendToAll(namePacket);
	}
	
	if(!(ownerName.equals(entityplayer.getCommandSenderName()) && ownerUUID.equals(entityplayer.getUniqueID()))) {
		return false;
	}
	
	return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityplayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
}