本文整理汇总了Java中net.minecraft.stats.StatBase类的典型用法代码示例。如果您正苦于以下问题:Java StatBase类的具体用法?Java StatBase怎么用?Java StatBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StatBase类属于net.minecraft.stats包,在下文中一共展示了StatBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChangeForSpawn
import net.minecraft.stats.StatBase; //导入依赖的package包/类
@Override
public int getChangeForSpawn(SpawnEventDetails details) {
int brokenBlocks = PlayerAreaStatAccumulator.getStatForPlayersInArea(type,details.entity,128,(player)->{
int accum = 0;
for(StatBase brokenStat : StatList.MINE_BLOCK_STATS) {
accum+=player.getStatFile().readStat(brokenStat);
}
return accum;
});
int contribution = (int)(((double)brokenBlocks * difficultyPerHundredBlocks) / 100);
if(maxAddedDifficulty>=0){
contribution = Math.min(contribution,maxAddedDifficulty);
}
return contribution;
}
示例2: addStat
import net.minecraft.stats.StatBase; //导入依赖的package包/类
/**
* Adds a value to a statistic field.
*/
public void addStat(StatBase stat, int amount)
{
if (stat != null)
{
this.statsFile.increaseStat(this, stat, amount);
for (ScoreObjective scoreobjective : this.getWorldScoreboard().getObjectivesFromCriteria(stat.func_150952_k()))
{
this.getWorldScoreboard().getValueFromObjective(this.getName(), scoreobjective).increseScore(amount);
}
if (this.statsFile.func_150879_e())
{
this.statsFile.func_150876_a(this);
}
}
}
示例3: func_175145_a
import net.minecraft.stats.StatBase; //导入依赖的package包/类
public void func_175145_a(StatBase p_175145_1_)
{
if (p_175145_1_ != null)
{
this.statsFile.unlockAchievement(this, p_175145_1_, 0);
for (ScoreObjective scoreobjective : this.getWorldScoreboard().getObjectivesFromCriteria(p_175145_1_.func_150952_k()))
{
this.getWorldScoreboard().getValueFromObjective(this.getName(), scoreobjective).setScorePoints(0);
}
if (this.statsFile.func_150879_e())
{
this.statsFile.func_150876_a(this);
}
}
}
示例4: readPacketData
import net.minecraft.stats.StatBase; //导入依赖的package包/类
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
int i = buf.readVarIntFromBuffer();
this.field_148976_a = Maps.<StatBase, Integer>newHashMap();
for (int j = 0; j < i; ++j)
{
StatBase statbase = StatList.getOneShotStat(buf.readStringFromBuffer(32767));
int k = buf.readVarIntFromBuffer();
if (statbase != null)
{
this.field_148976_a.put(statbase, Integer.valueOf(k));
}
}
}
示例5: addTabCompletionOptions
import net.minecraft.stats.StatBase; //导入依赖的package包/类
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
if (args.length == 1)
{
return getListOfStringsMatchingLastWord(args, new String[] {"give", "take"});
}
else if (args.length != 2)
{
return args.length == 3 ? getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()) : null;
}
else
{
List<String> list = Lists.<String>newArrayList();
for (StatBase statbase : StatList.allStats)
{
list.add(statbase.statId);
}
return getListOfStringsMatchingLastWord(args, list);
}
}
示例6: getTabCompletionOptions
import net.minecraft.stats.StatBase; //导入依赖的package包/类
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
if (args.length == 1)
{
/**
* Returns a List of strings (chosen from the given strings) which the last word in the given string array
* is a beginning-match for. (Tab completion).
*/
return getListOfStringsMatchingLastWord(args, new String[] {"give", "take"});
}
else if (args.length != 2)
{
return args.length == 3 ? getListOfStringsMatchingLastWord(args, server.getAllUsernames()) : Collections.<String>emptyList();
}
else
{
List<String> list = Lists.<String>newArrayList();
for (StatBase statbase : AchievementList.ACHIEVEMENTS)
{
list.add(statbase.statId);
}
return getListOfStringsMatchingLastWord(args, list);
}
}
示例7: buildAchievementStats
import net.minecraft.stats.StatBase; //导入依赖的package包/类
/** 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)
{
StatFileWriter sfw = player.getStatFile();
json.addProperty("DistanceTravelled",
sfw.readStat((StatBase)StatList.distanceWalkedStat)
+ sfw.readStat((StatBase)StatList.distanceSwumStat)
+ sfw.readStat((StatBase)StatList.distanceDoveStat)
+ sfw.readStat((StatBase)StatList.distanceFallenStat)
); // TODO: there are many other ways of moving!
json.addProperty("TimeAlive", sfw.readStat((StatBase)StatList.timeSinceDeathStat));
json.addProperty("MobsKilled", sfw.readStat((StatBase)StatList.mobKillsStat));
json.addProperty("PlayersKilled", sfw.readStat((StatBase)StatList.playerKillsStat));
json.addProperty("DamageTaken", sfw.readStat((StatBase)StatList.damageTakenStat));
/* 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)
*/
}
示例8: addStat
import net.minecraft.stats.StatBase; //导入依赖的package包/类
/**
* Adds a value to a statistic field.
*/
public void addStat(StatBase stat, int amount)
{
if (stat != null)
{
this.statsFile.increaseStat(this, stat, amount);
for (ScoreObjective scoreobjective : this.getWorldScoreboard().getObjectivesFromCriteria(stat.getCriteria()))
{
this.getWorldScoreboard().getOrCreateScore(this.getName(), scoreobjective).increaseScore(amount);
}
if (this.statsFile.hasUnsentAchievement())
{
this.statsFile.sendStats(this);
}
}
}
示例9: takeStat
import net.minecraft.stats.StatBase; //导入依赖的package包/类
public void takeStat(StatBase stat)
{
if (stat != null)
{
this.statsFile.unlockAchievement(this, stat, 0);
for (ScoreObjective scoreobjective : this.getWorldScoreboard().getObjectivesFromCriteria(stat.getCriteria()))
{
this.getWorldScoreboard().getOrCreateScore(this.getName(), scoreobjective).setScorePoints(0);
}
if (this.statsFile.hasUnsentAchievement())
{
this.statsFile.sendStats(this);
}
}
}
示例10: readPacketData
import net.minecraft.stats.StatBase; //导入依赖的package包/类
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
int i = buf.readVarIntFromBuffer();
this.statisticMap = Maps.<StatBase, Integer>newHashMap();
for (int j = 0; j < i; ++j)
{
StatBase statbase = StatList.getOneShotStat(buf.readStringFromBuffer(32767));
int k = buf.readVarIntFromBuffer();
if (statbase != null)
{
this.statisticMap.put(statbase, Integer.valueOf(k));
}
}
}
示例11: getTabCompletionOptions
import net.minecraft.stats.StatBase; //导入依赖的package包/类
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
if (args.length == 1)
{
return getListOfStringsMatchingLastWord(args, new String[] {"give", "take"});
}
else if (args.length != 2)
{
return args.length == 3 ? getListOfStringsMatchingLastWord(args, server.getAllUsernames()) : Collections.<String>emptyList();
}
else
{
List<String> list = Lists.<String>newArrayList();
for (StatBase statbase : AchievementList.ACHIEVEMENTS)
{
list.add(statbase.statId);
}
return getListOfStringsMatchingLastWord(args, list);
}
}
示例12: addStat
import net.minecraft.stats.StatBase; //导入依赖的package包/类
/**
* Adds a value to a statistic field.
*/
public void addStat(StatBase stat, int amount)
{
if (stat != null)
{
if (stat.isAchievement() && net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.AchievementEvent(this, (net.minecraft.stats.Achievement) stat))) return;
this.statsFile.increaseStat(this, stat, amount);
for (ScoreObjective scoreobjective : this.getWorldScoreboard().getObjectivesFromCriteria(stat.getCriteria()))
{
this.getWorldScoreboard().getOrCreateScore(this.getName(), scoreobjective).increaseScore(amount);
}
if (this.statsFile.hasUnsentAchievement())
{
this.statsFile.sendStats(this);
}
}
}
示例13: getStatForPlayersInArea
import net.minecraft.stats.StatBase; //导入依赖的package包/类
public static int getStatForPlayersInArea(MultiplePlayerCombineType type, StatBase stat, EntityLiving entity, int radius) {
return getStatForPlayersInArea(type,entity,radius, (player)->{
try {
return player.getStatFile().readStat(stat);
}catch(Exception e){
//catch a case where the stat is not defined
return 0;
}
});
}
示例14: drawSlot
import net.minecraft.stats.StatBase; //导入依赖的package包/类
protected void drawSlot(int entryID, int insideLeft, int yPos, int insideSlotHeight, int mouseXIn, int mouseYIn)
{
StatBase statbase = (StatBase)StatList.BASIC_STATS.get(entryID);
GuiStats.this.drawString(GuiStats.this.fontRendererObj, statbase.getStatName().getUnformattedText(), insideLeft + 2, yPos + 1, entryID % 2 == 0 ? 16777215 : 9474192);
String s = statbase.format(GuiStats.this.stats.readStat(statbase));
GuiStats.this.drawString(GuiStats.this.fontRendererObj, s, insideLeft + 2 + 213 - GuiStats.this.fontRendererObj.getStringWidth(s), yPos + 1, entryID % 2 == 0 ? 16777215 : 9474192);
}
示例15: writePacketData
import net.minecraft.stats.StatBase; //导入依赖的package包/类
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeVarIntToBuffer(this.field_148976_a.size());
for (Entry<StatBase, Integer> entry : this.field_148976_a.entrySet())
{
buf.writeString(((StatBase)entry.getKey()).statId);
buf.writeVarIntToBuffer(((Integer)entry.getValue()).intValue());
}
}