Java Code Examples for net.minecraft.stats.StatList#func_151177_a()

The following examples show how to use net.minecraft.stats.StatList#func_151177_a() . 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: ConsoleInputGui.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the screen and all the components in it.
 */
@SuppressWarnings("unchecked")
@Override
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) {
    drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
    if (this.inputField.getText().length() == 0) {
        this.inputField.setText("/");
    }
    if (this.inputField.getText().charAt(0) != '/') {
        this.inputField.setText("/" + this.inputField.getText());
    }
    this.inputField.drawTextBox();
    IChatComponent ichatcomponent = EHacksGui.clickGui.consoleGui.getChatComponent(Mouse.getX(), Mouse.getY());

    if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() != null) {
        HoverEvent hoverevent = ichatcomponent.getChatStyle().getChatHoverEvent();

        if (null != hoverevent.getAction()) {
            switch (hoverevent.getAction()) {
                case SHOW_ITEM:
                    ItemStack itemstack = null;
                    try {
                        NBTBase nbtbase = JsonToNBT.func_150315_a(hoverevent.getValue().getUnformattedText());

                        if (nbtbase instanceof NBTTagCompound) {
                            itemstack = ItemStack.loadItemStackFromNBT((NBTTagCompound) nbtbase);
                        }
                    } catch (NBTException ignored) {
                    }
                    if (itemstack != null) {
                        this.renderToolTip(itemstack, p_73863_1_, p_73863_2_);
                    } else {
                        this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid Item!", p_73863_1_, p_73863_2_);
                    }
                    break;
                case SHOW_TEXT:
                    this.func_146283_a(Splitter.on("\n").splitToList(hoverevent.getValue().getFormattedText()), p_73863_1_, p_73863_2_);
                    break;
                case SHOW_ACHIEVEMENT:
                    StatBase statbase = StatList.func_151177_a(hoverevent.getValue().getUnformattedText());
                    if (statbase != null) {
                        IChatComponent ichatcomponent1 = statbase.func_150951_e();
                        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("stats.tooltip.type." + (statbase.isAchievement() ? "achievement" : "statistic"));
                        chatcomponenttranslation.getChatStyle().setItalic(Boolean.TRUE);
                        String s = statbase instanceof Achievement ? ((Achievement) statbase).getDescription() : null;
                        ArrayList<String> arraylist = Lists.newArrayList(ichatcomponent1.getFormattedText(), chatcomponenttranslation.getFormattedText());

                        if (s != null) {
                            arraylist.addAll(this.fontRendererObj.listFormattedStringToWidth(s, 150));
                        }

                        this.func_146283_a(arraylist, p_73863_1_, p_73863_2_);
                    } else {
                        this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid statistic/achievement!", p_73863_1_, p_73863_2_);
                    }
                    break;
                default:
                    break;
            }
        }

        GL11.glDisable(GL11.GL_LIGHTING);
    }

    super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
}
 
Example 2
Source File: CraftStatistic.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public static net.minecraft.stats.StatBase getNMSStatistic(org.bukkit.Statistic statistic) {
    return StatList.func_151177_a(statistics.inverse().get(statistic));
}
 
Example 3
Source File: CraftStatistic.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public static net.minecraft.stats.Achievement getNMSAchievement(org.bukkit.Achievement achievement) {
    return (net.minecraft.stats.Achievement) StatList.func_151177_a(achievements.inverse().get(achievement));
}