本文整理汇总了Java中me.ichun.mods.ichunutil.common.core.util.EntityHelper.getPlayerPersistentData方法的典型用法代码示例。如果您正苦于以下问题:Java EntityHelper.getPlayerPersistentData方法的具体用法?Java EntityHelper.getPlayerPersistentData怎么用?Java EntityHelper.getPlayerPersistentData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类me.ichun.mods.ichunutil.common.core.util.EntityHelper
的用法示例。
在下文中一共展示了EntityHelper.getPlayerPersistentData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerLogin
import me.ichun.mods.ichunutil.common.core.util.EntityHelper; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event)
{
NBTTagCompound tag = EntityHelper.getPlayerPersistentData(event.player, "GuiltTripSave");
int size = tag.getInteger("size");
for(int i = 0; i < size; i++)
{
ArrayList<KillInfo> kills = GuiltTrip.eventHandlerServer.playerKills.get(event.player.getName());
if(kills == null)
{
kills = new ArrayList<>();
GuiltTrip.eventHandlerServer.playerKills.put(event.player.getName(), kills);
}
kills.add(KillInfo.createKillInfoFromTag(tag.getCompoundTag("kill_" + i)));
}
GuiltTrip.eventHandlerServer.updatePlayersOnKill(event.player.getName(), null);
GuiltTrip.eventHandlerServer.updatePlayersOnKill(null, event.player.getName());
}
示例2: createKillInfoFromEntity
import me.ichun.mods.ichunutil.common.core.util.EntityHelper; //导入方法依赖的package包/类
public static KillInfo createKillInfoFromEntity(EntityLivingBase living)
{
NBTTagCompound tag = new NBTTagCompound();
if(living instanceof EntityPlayer || living.writeToNBTOptional(tag))
{
KillInfo info = new KillInfo();
if(living instanceof EntityPlayer)
{
NBTTagCompound persistent = EntityHelper.getPlayerPersistentData((EntityPlayer)living);
NBTTagCompound tempTag = persistent.getCompoundTag("GuiltTripSave");
persistent.setTag("GuiltTripSave", new NBTTagCompound());
living.writeToNBT(tag);
tag = tag.copy();
persistent.setTag("GuiltTripSave", tempTag);
info.playerName = living.getName();
}
tag.setShort("HurtTime", (short)0);
tag.setShort("DeathTime", (short)0);
tag.setFloat("HealF", 1);
tag.setShort("Health", (short)1);
info.tag = tag;
return info;
}
return null;
}
示例3: addPlayerKill
import me.ichun.mods.ichunutil.common.core.util.EntityHelper; //导入方法依赖的package包/类
public boolean addPlayerKill(EntityPlayer player, EntityLivingBase killed)//returns true if the kill was added
{
if(GuiltTrip.config.allKills != 1)
{
if(killed instanceof EntityPlayer && GuiltTrip.config.playerKills != 1 || killed instanceof EntityAgeable && !(killed instanceof IMob) && GuiltTrip.config.animalKills != 1 || killed instanceof EntityCreature && !(killed instanceof EntityAgeable && !(killed instanceof IMob)) && GuiltTrip.config.mobKills != 1)
{
return false;
}
}
ArrayList<KillInfo> kills = playerKills.get(player.getName());
if(kills == null)
{
kills = new ArrayList<>();
playerKills.put(player.getName(), kills);
}
KillInfo info = KillInfo.createKillInfoFromEntity(killed);
if(info != null)
{
if(killed instanceof EntityAgeable && !(killed instanceof IMob))
{
float mag = GuiltTrip.config.animalGuiltMultiplier;
if(killed.hasCustomName())
{
mag *= 1.5F;
}
if(killed.isChild())
{
mag *= 1.5F;
}
info.maxAge = (int)((float)info.maxAge * mag);
}
if(killed instanceof EntityPlayer && GuiltTrip.config.playerKillsLasting == 1)
{
info.maxAge = 0;
}
kills.add(info);
while(kills.size() > GuiltTrip.config.maxGhosts)
{
kills.remove(0);
}
NBTTagCompound tag = EntityHelper.getPlayerPersistentData(player, "GuiltTripSave");
tag.setInteger("size", kills.size());
for(int i = 0; i < kills.size(); i++)
{
tag.setTag("kill_" + i, kills.get(i).getTag());
}
return true;
}
return false;
}