net.minecraft.stats.StatBase Java Examples

The following examples show how to use net.minecraft.stats.StatBase. 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: CraftStatistic.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static StatBase getMaterialStatistic(Statistic stat, Material material) {
    try {
        if (stat == Statistic.MINE_BLOCK) {
            return StatList.getBlockStats(CraftMagicNumbers.getBlock(material)); // PAIL: getMineBlockStatistic
        }
        if (stat == Statistic.CRAFT_ITEM) {
            return StatList.getCraftStats(CraftMagicNumbers.getItem(material)); // PAIL: getCraftItemStatistic
        }
        if (stat == Statistic.USE_ITEM) {
            return StatList.getObjectUseStats(CraftMagicNumbers.getItem(material)); // PAIL: getUseItemStatistic
        }
        if (stat == Statistic.BREAK_ITEM) {
            return StatList.getObjectBreakStats(CraftMagicNumbers.getItem(material)); // PAIL: getBreakItemStatistic
        }
        if (stat == Statistic.PICKUP) {
            return StatList.getObjectsPickedUpStats(CraftMagicNumbers.getItem(material)); // PAIL: getPickupStatistic
        }
        if (stat == Statistic.DROP) {
            return StatList.getDroppedObjectStats(CraftMagicNumbers.getItem(material)); // PAIL: getDropItemStatistic
        }
    } catch (ArrayIndexOutOfBoundsException e) {
        return null;
    }
    return null;
}
 
Example #2
Source File: CraftStatistic.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static Material getMaterialFromStatistic(StatBase statistic) {
    String statisticString = statistic.statId;
    String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
    Item item = Item.REGISTRY.getObject(new ResourceLocation(val));
    if (item != null) {
        return Material.getMaterial(Item.getIdFromItem(item));
    }
    Block block = Block.REGISTRY.getObject(new ResourceLocation(val));
    if (block != null) {
        return Material.getMaterial(Block.getIdFromBlock(block));
    }
    try {
        return Material.getMaterial(Integer.parseInt(val));
    } catch (NumberFormatException e) {
        return null;
    }
}
 
Example #3
Source File: JSONWorldDataHelper.java    From malmo with MIT License 6 votes vote down vote up
/** Builds the basic achievement world data to be used as observation signals by the listener.
 * @param json a JSON object into which the achievement stats will be added.
 */
public static void buildAchievementStats(JsonObject json, EntityPlayerMP player)
{
    StatisticsManagerServer sfw = player.getStatFile();
    json.addProperty("DistanceTravelled", 
            sfw.readStat((StatBase)StatList.WALK_ONE_CM) 
            + sfw.readStat((StatBase)StatList.SWIM_ONE_CM)
            + sfw.readStat((StatBase)StatList.DIVE_ONE_CM) 
            + sfw.readStat((StatBase)StatList.FALL_ONE_CM)
            ); // TODO: there are many other ways of moving!
    json.addProperty("TimeAlive", sfw.readStat((StatBase)StatList.TIME_SINCE_DEATH));
    json.addProperty("MobsKilled", sfw.readStat((StatBase)StatList.MOB_KILLS));
    json.addProperty("PlayersKilled", sfw.readStat((StatBase)StatList.PLAYER_KILLS));
    json.addProperty("DamageTaken", sfw.readStat((StatBase)StatList.DAMAGE_TAKEN));
    json.addProperty("DamageDealt", sfw.readStat((StatBase)StatList.DAMAGE_DEALT));

    /* Other potential reinforcement signals that may be worth researching:
    json.addProperty("BlocksDestroyed", sfw.readStat((StatBase)StatList.objectBreakStats) - but objectBreakStats is an array of 32000 StatBase objects - indexed by block type.);
    json.addProperty("Blocked", ev.player.isMovementBlocked()) - but isMovementBlocker() is a protected method (can get round this with reflection)
    */
}
 
Example #4
Source File: CraftStatistic.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public static StatBase getEntityStatistic(Statistic stat, EntityType entity) {
    EntityList.EntityEggInfo monsteregginfo = EntityList.ENTITY_EGGS.get(new ResourceLocation(entity.getName()));

    if (monsteregginfo != null) {
        if (stat == Statistic.KILL_ENTITY) {
            return monsteregginfo.killEntityStat;
        }
        if (stat == Statistic.ENTITY_KILLED_BY) {
            return monsteregginfo.entityKilledByStat;
        }
    }
    return null;
}
 
Example #5
Source File: CraftStatistic.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static Statistic getBukkitStatistic(StatBase statistic) {
    return getBukkitStatisticByName(statistic.statId);
}
 
Example #6
Source File: CraftStatistic.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static StatBase getNMSStatistic(Statistic statistic) {
    return StatList.getOneShotStat(statistics.inverse().get(statistic));
}
 
Example #7
Source File: CraftStatistic.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static EntityType getEntityTypeFromStatistic(StatBase statistic) {
    String statisticString = statistic.statId;
    return EntityType.fromName(statisticString.substring(statisticString.lastIndexOf(".") + 1));
}
 
Example #8
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 #9
Source File: EntityDrone.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void addStat(StatBase par1StatBase, int par2){}