当前位置: 首页>>代码示例>>Java>>正文


Java EntityHelper.getPlayerPersistentData方法代码示例

本文整理汇总了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());
}
 
开发者ID:iChun,项目名称:GuiltTrip,代码行数:20,代码来源:EventHandlerServer.java

示例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;
}
 
开发者ID:iChun,项目名称:GuiltTrip,代码行数:29,代码来源:KillInfo.java

示例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;
}
 
开发者ID:iChun,项目名称:GuiltTrip,代码行数:52,代码来源:EventHandlerServer.java


注:本文中的me.ichun.mods.ichunutil.common.core.util.EntityHelper.getPlayerPersistentData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。