Java Code Examples for net.minecraft.util.StringUtils

The following are top voted examples for showing how to use net.minecraft.util.StringUtils. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Bewitchment   File: BrewUtils.java   View source code 6 votes vote down vote up
@SideOnly(Side.CLIENT)
public static void addBrewTooltip(ItemStack stack, List<String> tooltip) {
	List<BrewEffect> brewsFromStack = BrewUtils.getBrewsFromStack(stack);
	for (BrewEffect effect : brewsFromStack) {
		IBrew brew = effect.getBrew();

		String name = " - " + I18n.format("brew." + brew.getName() + ".tooltip") + " ";
		String amplifier = (effect.getAmplifier() <= 0) ? "" : (RomanNumber.getRoman(effect.getAmplifier())) + " ";
		String duration = effect.isInstant() ? I18n.format("brew.instant") : StringUtils.ticksToElapsedTime(effect.getDuration());

		tooltip.add(TextFormatting.DARK_AQUA + "" + TextFormatting.ITALIC + name + amplifier + "(" + duration + ")");
	}
	if (brewsFromStack.isEmpty()) {
		tooltip.add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + "---");
	}
}
 
Example 2
Project: DecompiledMinecraft   File: PreYggdrasilConverter.java   View source code 6 votes vote down vote up
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
    String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
    {
        public boolean apply(String p_apply_1_)
        {
            return !StringUtils.isNullOrEmpty(p_apply_1_);
        }
    }), String.class);

    if (server.isServerInOnlineMode())
    {
        server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
    }
    else
    {
        for (String s : astring)
        {
            UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
            GameProfile gameprofile = new GameProfile(uuid, s);
            callback.onProfileLookupSucceeded(gameprofile);
        }
    }
}
 
Example 3
Project: DecompiledMinecraft   File: TileEntitySkull.java   View source code 6 votes vote down vote up
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.skullType = compound.getByte("SkullType");
    this.skullRotation = compound.getByte("Rot");

    if (this.skullType == 3)
    {
        if (compound.hasKey("Owner", 10))
        {
            this.playerProfile = NBTUtil.readGameProfileFromNBT(compound.getCompoundTag("Owner"));
        }
        else if (compound.hasKey("ExtraType", 8))
        {
            String s = compound.getString("ExtraType");

            if (!StringUtils.isNullOrEmpty(s))
            {
                this.playerProfile = new GameProfile((UUID)null, s);
                this.updatePlayerProfile();
            }
        }
    }
}
 
Example 4
Project: DecompiledMinecraft   File: ItemEditableBook.java   View source code 6 votes vote down vote up
/**
 * allows items to add custom lines of information to the mouseover description
 */
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
    if (stack.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();
        String s = nbttagcompound.getString("author");

        if (!StringUtils.isNullOrEmpty(s))
        {
            tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocalFormatted("book.byAuthor", new Object[] {s}));
        }

        tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("book.generation." + nbttagcompound.getInteger("generation")));
    }
}
 
Example 5
Project: DecompiledMinecraft   File: GuiIngame.java   View source code 6 votes vote down vote up
public void renderDemo(ScaledResolution p_175185_1_)
{
    this.mc.mcProfiler.startSection("demo");
    String s = "";

    if (this.mc.theWorld.getTotalWorldTime() >= 120500L)
    {
        s = I18n.format("demo.demoExpired", new Object[0]);
    }
    else
    {
        s = I18n.format("demo.remainingTime", new Object[] {StringUtils.ticksToElapsedTime((int)(120500L - this.mc.theWorld.getTotalWorldTime()))});
    }

    int i = this.getFontRenderer().getStringWidth(s);
    this.getFontRenderer().drawStringWithShadow(s, (float)(p_175185_1_.getScaledWidth() - i - 10), 5.0F, 16777215);
    this.mc.mcProfiler.endSection();
}
 
Example 6
Project: DecompiledMinecraft   File: PreYggdrasilConverter.java   View source code 6 votes vote down vote up
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
    String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
    {
        public boolean apply(String p_apply_1_)
        {
            return !StringUtils.isNullOrEmpty(p_apply_1_);
        }
    }), String.class);

    if (server.isServerInOnlineMode())
    {
        server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
    }
    else
    {
        for (String s : astring)
        {
            UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
            GameProfile gameprofile = new GameProfile(uuid, s);
            callback.onProfileLookupSucceeded(gameprofile);
        }
    }
}
 
Example 7
Project: DecompiledMinecraft   File: TileEntitySkull.java   View source code 6 votes vote down vote up
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.skullType = compound.getByte("SkullType");
    this.skullRotation = compound.getByte("Rot");

    if (this.skullType == 3)
    {
        if (compound.hasKey("Owner", 10))
        {
            this.playerProfile = NBTUtil.readGameProfileFromNBT(compound.getCompoundTag("Owner"));
        }
        else if (compound.hasKey("ExtraType", 8))
        {
            String s = compound.getString("ExtraType");

            if (!StringUtils.isNullOrEmpty(s))
            {
                this.playerProfile = new GameProfile((UUID)null, s);
                this.updatePlayerProfile();
            }
        }
    }
}
 
Example 8
Project: CustomWorldGen   File: GuiIngame.java   View source code 6 votes vote down vote up
public void renderDemo(ScaledResolution scaledRes)
{
    this.mc.mcProfiler.startSection("demo");
    String s;

    if (this.mc.theWorld.getTotalWorldTime() >= 120500L)
    {
        s = I18n.format("demo.demoExpired", new Object[0]);
    }
    else
    {
        s = I18n.format("demo.remainingTime", new Object[] {StringUtils.ticksToElapsedTime((int)(120500L - this.mc.theWorld.getTotalWorldTime()))});
    }

    int i = this.getFontRenderer().getStringWidth(s);
    this.getFontRenderer().drawStringWithShadow(s, (float)(scaledRes.getScaledWidth() - i - 10), 5.0F, 16777215);
    this.mc.mcProfiler.endSection();
}
 
Example 9
Project: WirelessCharger   File: TilePersonalCharger.java   View source code 6 votes vote down vote up
public GameProfile updateGameprofile(GameProfile input) {
    if (input != null && !StringUtils.isNullOrEmpty(input.getName())) {
        if (input.isComplete() && input.getProperties().containsKey("textures")) {
            return input;
        } else if (profileCache != null && sessionService != null) {
            GameProfile gameprofile = profileCache.getGameProfileForUsername(input.getName());

            if (gameprofile == null) {
                return input;
            } else {
                Property property = (Property) Iterables.getFirst(gameprofile.getProperties().get("textures"), (Object) null);

                if (property == null) {
                    gameprofile = sessionService.fillProfileProperties(gameprofile, true);
                }

                return gameprofile;
            }
        } else {
            return input;
        }
    } else {
        return input;
    }
}
 
Example 10
Project: CustomWorldGen   File: TextComponentScore.java   View source code 6 votes vote down vote up
public void resolve(ICommandSender sender)
{
    MinecraftServer minecraftserver = sender.getServer();

    if (minecraftserver != null && minecraftserver.isAnvilFileSet() && StringUtils.isNullOrEmpty(this.value))
    {
        Scoreboard scoreboard = minecraftserver.worldServerForDimension(0).getScoreboard();
        ScoreObjective scoreobjective = scoreboard.getObjective(this.objective);

        if (scoreboard.entityHasObjective(this.name, scoreobjective))
        {
            Score score = scoreboard.getOrCreateScore(this.name, scoreobjective);
            this.setValue(String.format("%d", new Object[] {Integer.valueOf(score.getScorePoints())}));
            return;
        }
    }

    this.value = "";
}
 
Example 11
Project: BaseClient   File: ItemEditableBook.java   View source code 6 votes vote down vote up
/**
 * allows items to add custom lines of information to the mouseover description
 */
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
    if (stack.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();
        String s = nbttagcompound.getString("author");

        if (!StringUtils.isNullOrEmpty(s))
        {
            tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocalFormatted("book.byAuthor", new Object[] {s}));
        }

        tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("book.generation." + nbttagcompound.getInteger("generation")));
    }
}
 
Example 12
Project: BaseClient   File: NetHandlerPlayClient.java   View source code 6 votes vote down vote up
/**
 * Either updates the score with a specified value or removes the score for an objective
 */
public void handleUpdateScore(S3CPacketUpdateScore packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Scoreboard scoreboard = this.clientWorldController.getScoreboard();
    ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());

    if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.CHANGE)
    {
        Score score = scoreboard.getValueFromObjective(packetIn.getPlayerName(), scoreobjective);
        score.setScorePoints(packetIn.getScoreValue());
    }
    else if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.REMOVE)
    {
        if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
        }
        else if (scoreobjective != null)
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
        }
    }
}
 
Example 13
Project: BaseClient   File: GuiIngame.java   View source code 6 votes vote down vote up
public void renderDemo(ScaledResolution p_175185_1_)
{
    this.mc.mcProfiler.startSection("demo");
    String s = "";

    if (this.mc.theWorld.getTotalWorldTime() >= 120500L)
    {
        s = I18n.format("demo.demoExpired", new Object[0]);
    }
    else
    {
        s = I18n.format("demo.remainingTime", new Object[] {StringUtils.ticksToElapsedTime((int)(120500L - this.mc.theWorld.getTotalWorldTime()))});
    }

    int i = this.getFontRenderer().getStringWidth(s);
    this.getFontRenderer().drawStringWithShadow(s, (float)(p_175185_1_.getScaledWidth() - i - 10), 5.0F, 16777215);
    this.mc.mcProfiler.endSection();
}
 
Example 14
Project: BaseClient   File: TileEntitySkull.java   View source code 6 votes vote down vote up
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.skullType = compound.getByte("SkullType");
    this.skullRotation = compound.getByte("Rot");

    if (this.skullType == 3)
    {
        if (compound.hasKey("Owner", 10))
        {
            this.playerProfile = NBTUtil.readGameProfileFromNBT(compound.getCompoundTag("Owner"));
        }
        else if (compound.hasKey("ExtraType", 8))
        {
            String s = compound.getString("ExtraType");

            if (!StringUtils.isNullOrEmpty(s))
            {
                this.playerProfile = new GameProfile((UUID)null, s);
                this.updatePlayerProfile();
            }
        }
    }
}
 
Example 15
Project: BaseClient   File: ItemEditableBook.java   View source code 6 votes vote down vote up
/**
 * allows items to add custom lines of information to the mouseover description
 */
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
    if (stack.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();
        String s = nbttagcompound.getString("author");

        if (!StringUtils.isNullOrEmpty(s))
        {
            tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocalFormatted("book.byAuthor", new Object[] {s}));
        }

        tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("book.generation." + nbttagcompound.getInteger("generation")));
    }
}
 
Example 16
Project: BaseClient   File: NetHandlerPlayClient.java   View source code 6 votes vote down vote up
/**
 * Either updates the score with a specified value or removes the score for an
 * objective
 */
public void handleUpdateScore(S3CPacketUpdateScore packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
	Scoreboard scoreboard = this.clientWorldController.getScoreboard();
	ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());

	if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.CHANGE) {
		Score score = scoreboard.getValueFromObjective(packetIn.getPlayerName(), scoreobjective);
		score.setScorePoints(packetIn.getScoreValue());
	} else if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.REMOVE) {
		if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName())) {
			scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective) null);
		} else if (scoreobjective != null) {
			scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
		}
	}
}
 
Example 17
Project: BaseClient   File: TileEntitySkull.java   View source code 6 votes vote down vote up
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.skullType = compound.getByte("SkullType");
    this.skullRotation = compound.getByte("Rot");

    if (this.skullType == 3)
    {
        if (compound.hasKey("Owner", 10))
        {
            this.playerProfile = NBTUtil.readGameProfileFromNBT(compound.getCompoundTag("Owner"));
        }
        else if (compound.hasKey("ExtraType", 8))
        {
            String s = compound.getString("ExtraType");

            if (!StringUtils.isNullOrEmpty(s))
            {
                this.playerProfile = new GameProfile((UUID)null, s);
                this.updatePlayerProfile();
            }
        }
    }
}
 
Example 18
Project: Zombe-Modpack   File: NetHandlerPlayClient.java   View source code 6 votes vote down vote up
/**
 * Either updates the score with a specified value or removes the score for an objective
 */
public void handleUpdateScore(SPacketUpdateScore packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Scoreboard scoreboard = this.clientWorldController.getScoreboard();
    ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());

    if (packetIn.getScoreAction() == SPacketUpdateScore.Action.CHANGE)
    {
        Score score = scoreboard.getOrCreateScore(packetIn.getPlayerName(), scoreobjective);
        score.setScorePoints(packetIn.getScoreValue());
    }
    else if (packetIn.getScoreAction() == SPacketUpdateScore.Action.REMOVE)
    {
        if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
        }
        else if (scoreobjective != null)
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
        }
    }
}
 
Example 19
Project: Backmemed   File: ItemWrittenBook.java   View source code 6 votes vote down vote up
/**
 * allows items to add custom lines of information to the mouseover description
 */
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
    if (stack.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();
        String s = nbttagcompound.getString("author");

        if (!StringUtils.isNullOrEmpty(s))
        {
            tooltip.add(TextFormatting.GRAY + I18n.translateToLocalFormatted("book.byAuthor", new Object[] {s}));
        }

        tooltip.add(TextFormatting.GRAY + I18n.translateToLocal("book.generation." + nbttagcompound.getInteger("generation")));
    }
}
 
Example 20
Project: Backmemed   File: NetHandlerPlayClient.java   View source code 6 votes vote down vote up
/**
 * Either updates the score with a specified value or removes the score for an objective
 */
public void handleUpdateScore(SPacketUpdateScore packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Scoreboard scoreboard = this.clientWorldController.getScoreboard();
    ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());

    if (packetIn.getScoreAction() == SPacketUpdateScore.Action.CHANGE)
    {
        Score score = scoreboard.getOrCreateScore(packetIn.getPlayerName(), scoreobjective);
        score.setScorePoints(packetIn.getScoreValue());
    }
    else if (packetIn.getScoreAction() == SPacketUpdateScore.Action.REMOVE)
    {
        if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
        }
        else if (scoreobjective != null)
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
        }
    }
}
 
Example 21
Project: Backmemed   File: GuiIngame.java   View source code 6 votes vote down vote up
public void renderDemo(ScaledResolution scaledRes)
{
    this.mc.mcProfiler.startSection("demo");
    String s;

    if (this.mc.world.getTotalWorldTime() >= 120500L)
    {
        s = I18n.format("demo.demoExpired", new Object[0]);
    }
    else
    {
        s = I18n.format("demo.remainingTime", new Object[] {StringUtils.ticksToElapsedTime((int)(120500L - this.mc.world.getTotalWorldTime()))});
    }

    int i = this.getFontRenderer().getStringWidth(s);
    this.getFontRenderer().drawStringWithShadow(s, (float)(scaledRes.getScaledWidth() - i - 10), 5.0F, 16777215);
    this.mc.mcProfiler.endSection();
}
 
Example 22
Project: CustomWorldGen   File: TileEntityStructure.java   View source code 6 votes vote down vote up
public boolean save(boolean p_189712_1_)
{
    if (this.mode == TileEntityStructure.Mode.SAVE && !this.worldObj.isRemote && !StringUtils.isNullOrEmpty(this.name))
    {
        BlockPos blockpos = this.getPos().add(this.position);
        WorldServer worldserver = (WorldServer)this.worldObj;
        MinecraftServer minecraftserver = this.worldObj.getMinecraftServer();
        TemplateManager templatemanager = worldserver.getStructureTemplateManager();
        Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(this.name));
        template.takeBlocksFromWorld(this.worldObj, blockpos, this.size, !this.ignoreEntities, Blocks.STRUCTURE_VOID);
        template.setAuthor(this.author);
        return !p_189712_1_ || templatemanager.writeTemplate(minecraftserver, new ResourceLocation(this.name));
    }
    else
    {
        return false;
    }
}
 
Example 23
Project: Backmemed   File: GuiMainMenu.java   View source code 6 votes vote down vote up
/**
 * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
 */
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
	super.mouseClicked(mouseX, mouseY, mouseButton);

	synchronized (this.threadLock) {
		if (!this.openGLWarning1.isEmpty() && !StringUtils.isNullOrEmpty(this.openGLWarningLink)
				&& mouseX >= this.openGLWarningX1 && mouseX <= this.openGLWarningX2
				&& mouseY >= this.openGLWarningY1 && mouseY <= this.openGLWarningY2) {
			GuiConfirmOpenLink guiconfirmopenlink = new GuiConfirmOpenLink(this, this.openGLWarningLink, 13, true);
			guiconfirmopenlink.disableSecurityWarning();
			this.mc.displayGuiScreen(guiconfirmopenlink);
		}
	}

	if (this.areRealmsNotificationsEnabled()) {
		this.realmsNotification.mouseClicked(mouseX, mouseY, mouseButton);
	}

	if (Reflector.ForgeHooksClient_mainMenuMouseClick.exists()) {
		Reflector.call(Reflector.ForgeHooksClient_mainMenuMouseClick,
				new Object[] { Integer.valueOf(mouseX), Integer.valueOf(mouseY), Integer.valueOf(mouseButton),
						this.fontRendererObj, Integer.valueOf(this.width) });
	}
}
 
Example 24
Project: Backmemed   File: PreYggdrasilConverter.java   View source code 6 votes vote down vote up
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
    String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
    {
        public boolean apply(@Nullable String p_apply_1_)
        {
            return !StringUtils.isNullOrEmpty(p_apply_1_);
        }
    }), String.class);

    if (server.isServerInOnlineMode())
    {
        server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
    }
    else
    {
        for (String s : astring)
        {
            UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
            GameProfile gameprofile = new GameProfile(uuid, s);
            callback.onProfileLookupSucceeded(gameprofile);
        }
    }
}
 
Example 25
Project: Backmemed   File: TextComponentScore.java   View source code 6 votes vote down vote up
public void resolve(ICommandSender sender)
{
    MinecraftServer minecraftserver = sender.getServer();

    if (minecraftserver != null && minecraftserver.isAnvilFileSet() && StringUtils.isNullOrEmpty(this.value))
    {
        Scoreboard scoreboard = minecraftserver.worldServerForDimension(0).getScoreboard();
        ScoreObjective scoreobjective = scoreboard.getObjective(this.objective);

        if (scoreboard.entityHasObjective(this.name, scoreobjective))
        {
            Score score = scoreboard.getOrCreateScore(this.name, scoreobjective);
            this.setValue(String.format("%d", new Object[] {Integer.valueOf(score.getScorePoints())}));
        }
        else
        {
            this.value = "";
        }
    }
}
 
Example 26
Project: Backmemed   File: TileEntityStructure.java   View source code 6 votes vote down vote up
public boolean save(boolean p_189712_1_)
{
    if (this.mode == TileEntityStructure.Mode.SAVE && !this.world.isRemote && !StringUtils.isNullOrEmpty(this.name))
    {
        BlockPos blockpos = this.getPos().add(this.position);
        WorldServer worldserver = (WorldServer)this.world;
        MinecraftServer minecraftserver = this.world.getMinecraftServer();
        TemplateManager templatemanager = worldserver.getStructureTemplateManager();
        Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(this.name));
        template.takeBlocksFromWorld(this.world, blockpos, this.size, !this.ignoreEntities, Blocks.STRUCTURE_VOID);
        template.setAuthor(this.author);
        return !p_189712_1_ || templatemanager.writeTemplate(minecraftserver, new ResourceLocation(this.name));
    }
    else
    {
        return false;
    }
}
 
Example 27
Project: Backmemed   File: TileEntitySkull.java   View source code 6 votes vote down vote up
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.skullType = compound.getByte("SkullType");
    this.skullRotation = compound.getByte("Rot");

    if (this.skullType == 3)
    {
        if (compound.hasKey("Owner", 10))
        {
            this.playerProfile = NBTUtil.readGameProfileFromNBT(compound.getCompoundTag("Owner"));
        }
        else if (compound.hasKey("ExtraType", 8))
        {
            String s = compound.getString("ExtraType");

            if (!StringUtils.isNullOrEmpty(s))
            {
                this.playerProfile = new GameProfile((UUID)null, s);
                this.updatePlayerProfile();
            }
        }
    }
}
 
Example 28
Project: CustomWorldGen   File: PreYggdrasilConverter.java   View source code 6 votes vote down vote up
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
    String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
    {
        public boolean apply(@Nullable String p_apply_1_)
        {
            return !StringUtils.isNullOrEmpty(p_apply_1_);
        }
    }), String.class);

    if (server.isServerInOnlineMode())
    {
        server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
    }
    else
    {
        for (String s : astring)
        {
            UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
            GameProfile gameprofile = new GameProfile(uuid, s);
            callback.onProfileLookupSucceeded(gameprofile);
        }
    }
}
 
Example 29
Project: CustomWorldGen   File: TileEntitySkull.java   View source code 6 votes vote down vote up
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.skullType = compound.getByte("SkullType");
    this.skullRotation = compound.getByte("Rot");

    if (this.skullType == 3)
    {
        if (compound.hasKey("Owner", 10))
        {
            this.playerProfile = NBTUtil.readGameProfileFromNBT(compound.getCompoundTag("Owner"));
        }
        else if (compound.hasKey("ExtraType", 8))
        {
            String s = compound.getString("ExtraType");

            if (!StringUtils.isNullOrEmpty(s))
            {
                this.playerProfile = new GameProfile((UUID)null, s);
                this.updatePlayerProfile();
            }
        }
    }
}
 
Example 30
Project: CustomWorldGen   File: ItemWrittenBook.java   View source code 6 votes vote down vote up
/**
 * allows items to add custom lines of information to the mouseover description
 */
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
    if (stack.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();
        String s = nbttagcompound.getString("author");

        if (!StringUtils.isNullOrEmpty(s))
        {
            tooltip.add(TextFormatting.GRAY + I18n.translateToLocalFormatted("book.byAuthor", new Object[] {s}));
        }

        tooltip.add(TextFormatting.GRAY + I18n.translateToLocal("book.generation." + nbttagcompound.getInteger("generation")));
    }
}
 
Example 31
Project: CustomWorldGen   File: NetHandlerPlayClient.java   View source code 6 votes vote down vote up
/**
 * Either updates the score with a specified value or removes the score for an objective
 */
public void handleUpdateScore(SPacketUpdateScore packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Scoreboard scoreboard = this.clientWorldController.getScoreboard();
    ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());

    if (packetIn.getScoreAction() == SPacketUpdateScore.Action.CHANGE)
    {
        Score score = scoreboard.getOrCreateScore(packetIn.getPlayerName(), scoreobjective);
        score.setScorePoints(packetIn.getScoreValue());
    }
    else if (packetIn.getScoreAction() == SPacketUpdateScore.Action.REMOVE)
    {
        if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
        }
        else if (scoreobjective != null)
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
        }
    }
}
 
Example 32
Project: DecompiledMinecraft   File: ItemEditableBook.java   View source code 5 votes vote down vote up
public String getItemStackDisplayName(ItemStack stack)
{
    if (stack.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();
        String s = nbttagcompound.getString("title");

        if (!StringUtils.isNullOrEmpty(s))
        {
            return s;
        }
    }

    return super.getItemStackDisplayName(stack);
}
 
Example 33
Project: DecompiledMinecraft   File: PreYggdrasilConverter.java   View source code 5 votes vote down vote up
public static String getStringUUIDFromName(String p_152719_0_)
{
    if (!StringUtils.isNullOrEmpty(p_152719_0_) && p_152719_0_.length() <= 16)
    {
        final MinecraftServer minecraftserver = MinecraftServer.getServer();
        GameProfile gameprofile = minecraftserver.getPlayerProfileCache().getGameProfileForUsername(p_152719_0_);

        if (gameprofile != null && gameprofile.getId() != null)
        {
            return gameprofile.getId().toString();
        }
        else if (!minecraftserver.isSinglePlayer() && minecraftserver.isServerInOnlineMode())
        {
            final List<GameProfile> list = Lists.<GameProfile>newArrayList();
            ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
            {
                public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
                {
                    minecraftserver.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
                    list.add(p_onProfileLookupSucceeded_1_);
                }
                public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
                {
                    PreYggdrasilConverter.LOGGER.warn((String)("Could not lookup user whitelist entry for " + p_onProfileLookupFailed_1_.getName()), (Throwable)p_onProfileLookupFailed_2_);
                }
            };
            lookupNames(minecraftserver, Lists.newArrayList(new String[] {p_152719_0_}), profilelookupcallback);
            return list.size() > 0 && ((GameProfile)list.get(0)).getId() != null ? ((GameProfile)list.get(0)).getId().toString() : "";
        }
        else
        {
            return EntityPlayer.getUUID(new GameProfile((UUID)null, p_152719_0_)).toString();
        }
    }
    else
    {
        return p_152719_0_;
    }
}
 
Example 34
Project: DecompiledMinecraft   File: MobSpawnerBaseLogic.java   View source code 5 votes vote down vote up
public void writeToNBT(NBTTagCompound nbt)
{
    String s = this.getEntityNameToSpawn();

    if (!StringUtils.isNullOrEmpty(s))
    {
        nbt.setString("EntityId", s);
        nbt.setShort("Delay", (short)this.spawnDelay);
        nbt.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
        nbt.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
        nbt.setShort("SpawnCount", (short)this.spawnCount);
        nbt.setShort("MaxNearbyEntities", (short)this.maxNearbyEntities);
        nbt.setShort("RequiredPlayerRange", (short)this.activatingRangeFromPlayer);
        nbt.setShort("SpawnRange", (short)this.spawnRange);

        if (this.getRandomEntity() != null)
        {
            nbt.setTag("SpawnData", this.getRandomEntity().nbtData.copy());
        }

        if (this.getRandomEntity() != null || this.minecartToSpawn.size() > 0)
        {
            NBTTagList nbttaglist = new NBTTagList();

            if (this.minecartToSpawn.size() > 0)
            {
                for (MobSpawnerBaseLogic.WeightedRandomMinecart mobspawnerbaselogic$weightedrandomminecart : this.minecartToSpawn)
                {
                    nbttaglist.appendTag(mobspawnerbaselogic$weightedrandomminecart.toNBT());
                }
            }
            else
            {
                nbttaglist.appendTag(this.getRandomEntity().toNBT());
            }

            nbt.setTag("SpawnPotentials", nbttaglist);
        }
    }
}
 
Example 35
Project: DecompiledMinecraft   File: TileEntitySkull.java   View source code 5 votes vote down vote up
public static GameProfile updateGameprofile(GameProfile input)
{
    if (input != null && !StringUtils.isNullOrEmpty(input.getName()))
    {
        if (input.isComplete() && input.getProperties().containsKey("textures"))
        {
            return input;
        }
        else if (MinecraftServer.getServer() == null)
        {
            return input;
        }
        else
        {
            GameProfile gameprofile = MinecraftServer.getServer().getPlayerProfileCache().getGameProfileForUsername(input.getName());

            if (gameprofile == null)
            {
                return input;
            }
            else
            {
                Property property = (Property)Iterables.getFirst(gameprofile.getProperties().get("textures"), null);

                if (property == null)
                {
                    gameprofile = MinecraftServer.getServer().getMinecraftSessionService().fillProfileProperties(gameprofile, true);
                }

                return gameprofile;
            }
        }
    }
    else
    {
        return input;
    }
}
 
Example 36
Project: DecompiledMinecraft   File: ItemEditableBook.java   View source code 5 votes vote down vote up
public String getItemStackDisplayName(ItemStack stack)
{
    if (stack.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();
        String s = nbttagcompound.getString("title");

        if (!StringUtils.isNullOrEmpty(s))
        {
            return s;
        }
    }

    return super.getItemStackDisplayName(stack);
}
 
Example 37
Project: DecompiledMinecraft   File: PreYggdrasilConverter.java   View source code 5 votes vote down vote up
public static String getStringUUIDFromName(String p_152719_0_)
{
    if (!StringUtils.isNullOrEmpty(p_152719_0_) && p_152719_0_.length() <= 16)
    {
        final MinecraftServer minecraftserver = MinecraftServer.getServer();
        GameProfile gameprofile = minecraftserver.getPlayerProfileCache().getGameProfileForUsername(p_152719_0_);

        if (gameprofile != null && gameprofile.getId() != null)
        {
            return gameprofile.getId().toString();
        }
        else if (!minecraftserver.isSinglePlayer() && minecraftserver.isServerInOnlineMode())
        {
            final List<GameProfile> list = Lists.<GameProfile>newArrayList();
            ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
            {
                public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
                {
                    minecraftserver.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
                    list.add(p_onProfileLookupSucceeded_1_);
                }
                public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
                {
                    PreYggdrasilConverter.LOGGER.warn((String)("Could not lookup user whitelist entry for " + p_onProfileLookupFailed_1_.getName()), (Throwable)p_onProfileLookupFailed_2_);
                }
            };
            lookupNames(minecraftserver, Lists.newArrayList(new String[] {p_152719_0_}), profilelookupcallback);
            return list.size() > 0 && ((GameProfile)list.get(0)).getId() != null ? ((GameProfile)list.get(0)).getId().toString() : "";
        }
        else
        {
            return EntityPlayer.getUUID(new GameProfile((UUID)null, p_152719_0_)).toString();
        }
    }
    else
    {
        return p_152719_0_;
    }
}
 
Example 38
Project: DecompiledMinecraft   File: MobSpawnerBaseLogic.java   View source code 5 votes vote down vote up
public void writeToNBT(NBTTagCompound nbt)
{
    String s = this.getEntityNameToSpawn();

    if (!StringUtils.isNullOrEmpty(s))
    {
        nbt.setString("EntityId", s);
        nbt.setShort("Delay", (short)this.spawnDelay);
        nbt.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
        nbt.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
        nbt.setShort("SpawnCount", (short)this.spawnCount);
        nbt.setShort("MaxNearbyEntities", (short)this.maxNearbyEntities);
        nbt.setShort("RequiredPlayerRange", (short)this.activatingRangeFromPlayer);
        nbt.setShort("SpawnRange", (short)this.spawnRange);

        if (this.getRandomEntity() != null)
        {
            nbt.setTag("SpawnData", this.getRandomEntity().nbtData.copy());
        }

        if (this.getRandomEntity() != null || this.minecartToSpawn.size() > 0)
        {
            NBTTagList nbttaglist = new NBTTagList();

            if (this.minecartToSpawn.size() > 0)
            {
                for (MobSpawnerBaseLogic.WeightedRandomMinecart mobspawnerbaselogic$weightedrandomminecart : this.minecartToSpawn)
                {
                    nbttaglist.appendTag(mobspawnerbaselogic$weightedrandomminecart.toNBT());
                }
            }
            else
            {
                nbttaglist.appendTag(this.getRandomEntity().toNBT());
            }

            nbt.setTag("SpawnPotentials", nbttaglist);
        }
    }
}
 
Example 39
Project: CustomWorldGen   File: TileEntitySkull.java   View source code 5 votes vote down vote up
public static GameProfile updateGameprofile(GameProfile input)
{
    if (input != null && !StringUtils.isNullOrEmpty(input.getName()))
    {
        if (input.isComplete() && input.getProperties().containsKey("textures"))
        {
            return input;
        }
        else if (profileCache != null && sessionService != null)
        {
            GameProfile gameprofile = profileCache.getGameProfileForUsername(input.getName());

            if (gameprofile == null)
            {
                return input;
            }
            else
            {
                Property property = (Property)Iterables.getFirst(gameprofile.getProperties().get("textures"), null);

                if (property == null)
                {
                    gameprofile = sessionService.fillProfileProperties(gameprofile, true);
                }

                return gameprofile;
            }
        }
        else
        {
            return input;
        }
    }
    else
    {
        return input;
    }
}
 
Example 40
Project: DecompiledMinecraft   File: Potion.java   View source code 5 votes vote down vote up
public static String getDurationString(PotionEffect effect)
{
    if (effect.getIsPotionDurationMax())
    {
        return "**:**";
    }
    else
    {
        int i = effect.getDuration();
        return StringUtils.ticksToElapsedTime(i);
    }
}