Java 类net.minecraftforge.event.entity.player.PlayerDropsEvent 实例源码

项目:Clef    文件:EventHandlerServer.java   
@SubscribeEvent
public void onItemDrop(PlayerDropsEvent event)
{
    if(!event.getEntityPlayer().getEntityWorld().isRemote)
    {
        for(EntityItem item : event.getDrops())
        {
            if(item.getItem().getItem() == Clef.itemInstrument)
            {
                NBTTagCompound tag = item.getItem().getTagCompound();
                if(tag != null)
                {
                    String instName = tag.getString("itemName");
                    Instrument is = InstrumentLibrary.getInstrumentByName(instName);
                    if(is == null) //request the item then?
                    {
                        InstrumentLibrary.requestInstrument(instName, event.getEntityPlayer());
                    }
                }
            }
        }
    }
}
项目:4Space-5    文件:EventHandlerGC.java   
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent event)
{
    if (event.entityLiving instanceof EntityPlayerMP)
    {
        GCPlayerStats stats = GCPlayerStats.get((EntityPlayerMP) event.entityLiving);
        if (!event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
        {
            event.entityLiving.captureDrops = true;
            for (int i = stats.extendedInventory.getSizeInventory() - 1; i >= 0; i--)
            {
                ItemStack stack = stats.extendedInventory.getStackInSlot(i);

                if (stack != null)
                {
                    ((EntityPlayerMP) event.entityLiving).func_146097_a(stack, true, false);
                    stats.extendedInventory.setInventorySlotContents(i, null);
                }
            }
            event.entityLiving.captureDrops = false;
        }
    }
}
项目:CrystalMod    文件:EventHandler.java   
public void addPlayerHeads(PlayerDropsEvent event){
EntityPlayer player = event.getEntityPlayer();
DamageSource source = event.getSource();
Entity attacker = source.getSourceOfDamage();
    if(Config.playerHeadType == ItemDropType.NONE)return;
    if(player == null || player.getEntityWorld() == null)return;

    int rand = player.getEntityWorld().rand.nextInt(Math.max(Config.playerHeadDropChance / fixLooting(event.getLootingLevel()), 1));

    if(Config.playerHeadDropChance < 0 || rand !=0)
        return;
    if(Config.playerHeadType == ItemDropType.KILLED){
        if(attacker == null || !(attacker instanceof EntityPlayer) || attacker instanceof FakePlayer)
            return;
    }
    ItemStack skull = PlayerUtil.createPlayerHead(player);
    event.getDrops().add(ItemUtil.dropFromPlayer(player, skull, true));
  }
项目:Levels    文件:EventSoulBound.java   
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent event)
{
    EntityPlayer player = event.getEntityPlayer();
    Item item;

    for (int i = 0; i < event.getDrops().size(); i++)
    {
        item = event.getDrops().get(i).getEntityItem().getItem();

        if (item != null && (item instanceof ItemSword || item instanceof ItemShield || item instanceof ItemArmor || item instanceof ItemBow))
        {
            ItemStack stack = event.getDrops().get(i).getEntityItem();
            NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);

            if (nbt != null)
            {
                if (WeaponAttribute.SOUL_BOUND.hasAttribute(nbt) || ArmorAttribute.SOUL_BOUND.hasAttribute(nbt) || BowAttribute.SOUL_BOUND.hasAttribute(nbt) || ShieldAttribute.SOUL_BOUND.hasAttribute(nbt))
                {
                    event.getDrops().remove(i);
                    player.inventory.addItemStackToInventory(stack);
                }
            }
        }
    }
}
项目:Bagginses    文件:SoulBoundEventHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerDeath(PlayerDropsEvent evt) {
    if (evt.getEntityPlayer() == null || evt.getEntityPlayer() instanceof FakePlayer || evt.isCanceled()) {
        return;
    }
    if(evt.getEntityPlayer().world.getGameRules().getBoolean("keepInventory")) {
        return;
    }

    ListIterator<EntityItem> iter = evt.getDrops().listIterator();
    while (iter.hasNext()) {
        EntityItem ei = iter.next();
        ItemStack item = ei.getEntityItem();
        if(isSoulBound(item)) {
            if (addToPlayerInventory(evt.getEntityPlayer(), item)) {
                Bagginses.analytics.eventDesign("playerDied:Soulbound", Bagginses.analytics.userPrefix());
                iter.remove();
            }
        }
    }

}
项目:Cybernetica    文件:PlayerEventHandler.java   
/**
 * Stores cybernetic implants for a specific player in a hashmap on death
 * TODO this equips implants that aren't currently equipped as armor. Fot it so that it only stores implants equipped as armor
 * @param e the PlayersDropsEvent event
 */
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent e) {
    //the arraylist that will store all of the player's implants
    ArrayList<EntityItem> savedDrops = new ArrayList<EntityItem>();

    //iterate through all of the player drops (the items in the player's inventory) and save all the implants
    for (EntityItem i : e.drops) {
        if (i.getEntityItem().getItem() instanceof Implant) {
            savedDrops.add(i);
        }
    }

    //remove all of the found implants from the drops list so they don't spawn in world
    e.drops.removeAll(savedDrops);
    savedImplants.put(e.entityPlayer.getDisplayName(), savedDrops);
}
项目:D3Core    文件:DevPerks.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void deathEvent(PlayerDropsEvent event)
{
    try
    {
        if (D3Core.isDebug())
            perks = new JsonParser().parse(IOUtils.toString(new URL(CoreConstants.PERKS_URL), Charset.forName("UTF-8"))).getAsJsonObject();
        if (perks.has(event.getEntityPlayer().getName()))
        {
            JsonObject perk = perks.getAsJsonObject(event.getEntityPlayer().getName());
            if (perk.has("drop"))
            {
                ItemStack stack = getItemStackFromJson(perk.getAsJsonObject("drop"), 0, 1);
                if (stack == ItemStack.EMPTY) return;
                event.getDrops().add(new EntityItem(event.getEntityPlayer().getEntityWorld(), event.getEntityPlayer().posX, event.getEntityPlayer().posY, event.getEntityPlayer().posZ, stack));
            }
        }
    }
    catch (Exception e)
    {
        if (D3Core.isDebug()) e.printStackTrace();
    }
}
项目:EnderIO    文件:HandlerSoulBound.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerDeathLate(PlayerDropsEvent evt) {
  if (evt.getEntityPlayer() == null || evt.getEntityPlayer() instanceof FakePlayer || evt.isCanceled()) {
    return;
  }
  if (evt.getEntityPlayer().world.getGameRules().getBoolean("keepInventory")) {
    return;
  }

  Log.debug("Running onPlayerDeathLate logic for " + evt.getEntityPlayer().getName());

  ListIterator<EntityItem> iter = evt.getDrops().listIterator();
  while (iter.hasNext()) {
    EntityItem ei = iter.next();
    ItemStack item = ei.getEntityItem();
    if (isSoulBound(item)) {
      if (addToPlayerInventory(evt.getEntityPlayer(), item)) {
        iter.remove();
      }
    }
  }

}
项目:Mods    文件:TF2EventsCommon.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void dropFakeItems(PlayerDropsEvent event) {
    InventoryWearables inv = event.getEntityLiving().getCapability(TF2weapons.INVENTORY_CAP, null);
    for (int i = 3; i < 13; i++)
        if (inv.getStackInSlot(i) != null) {
            event.getEntityPlayer().dropItem(inv.getStackInSlot(i), true, false);
        }

    if(WeaponsCapability.get(event.getEntity()).isFeign())
        for(EntityItem item:event.getDrops()) {
            item.getEntityData().setBoolean("Fake", true);
            item.setAgeToCreativeDespawnTime();
        }
}
项目:CustomWorldGen    文件:ForgeEventFactory.java   
public static void onPlayerDrops(EntityPlayer player, DamageSource cause, List<EntityItem> capturedDrops, boolean recentlyHit)
{
    PlayerDropsEvent event = new PlayerDropsEvent(player, cause, capturedDrops, recentlyHit);
    if (!MinecraftForge.EVENT_BUS.post(event))
    {
        for (EntityItem item : capturedDrops)
        {
            player.dropItemAndGetStack(item);
        }
    }
}
项目:ExtraUtilities    文件:EventHandlerServer.java   
@SubscribeEvent
public void captureGoldenBagDrop(final PlayerDropsEvent event) {
    if (ExtraUtils.goldenBag == null) {
        return;
    }
    if (event.entity.getEntityData().getCompoundTag("PlayerPersisted").hasKey("XU|GoldenBags")) {
        return;
    }
    int j = 0;
    final NBTTagCompound t = new NBTTagCompound();
    for (int i = 0; i < event.drops.size(); ++i) {
        final ItemStack item = event.drops.get(i).getEntityItem();
        if (item != null && item.getItem() == ExtraUtils.goldenBag && ItemGoldenBag.isMagic(item)) {
            final NBTTagCompound tags = new NBTTagCompound();
            item.writeToNBT(tags);
            t.setTag("item_" + j, (NBTBase)tags);
            ++j;
            event.drops.remove(i);
            --i;
        }
    }
    t.setInteger("no_items", j);
    NBTTagCompound e;
    if (event.entityPlayer.getEntityData().hasKey("PlayerPersisted")) {
        e = event.entityPlayer.getEntityData().getCompoundTag("PlayerPersisted");
    }
    else {
        e = new NBTTagCompound();
        event.entityPlayer.getEntityData().setTag("PlayerPersisted", (NBTBase)e);
    }
    e.setTag("XU|GoldenBags", (NBTBase)t);
}
项目:LittleThings-old    文件:DisplayDeathCoords.java   
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent e)
{
    EntityPlayer player = e.getEntityPlayer();
    int x = (int) player.posX;
    int y = (int) player.posY;
    int z = (int) player.posZ;
    int dim = player.dimension;
    player.addChatComponentMessage(new TextComponentTranslation("message.littlethings.deathCoords", x, y, z));
    player.addChatComponentMessage(ITextComponent.Serializer.jsonToComponent(I18n.translateToLocal("message.littlethings.deathLinks")
            .replaceAll("%w%", String.valueOf(dim))
            .replaceAll("%x%", String.valueOf(x))
            .replaceAll("%y%", String.valueOf(y))
            .replaceAll("%z%", String.valueOf(z))));
}
项目:4Space-5    文件:EntityPlayer.java   
public void onDeath(DamageSource p_70645_1_)
{
    if (ForgeHooks.onLivingDeath(this, p_70645_1_)) {
        return;
    }
    super.onDeath(p_70645_1_);
    setSize(0.2F, 0.2F);
    setPosition(this.posX, this.posY, this.posZ);
    this.motionY = 0.1000000014901161D;

    this.captureDrops = true;
    this.capturedDrops.clear();
    if (getCommandSenderName().equals("Notch")) {
        func_146097_a(new ItemStack(Items.apple, 1), true, false);
    }
    if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
        this.inventory.dropAllItems();
    }
    this.captureDrops = false;
    if (!this.worldObj.isRemote)
    {
        PlayerDropsEvent event = new PlayerDropsEvent(this, p_70645_1_, this.capturedDrops, this.recentlyHit > 0);
        if (!MinecraftForge.EVENT_BUS.post(event)) {
            for (EntityItem item : this.capturedDrops) {
                joinEntityItemWithWorld(item);
            }
        }
    }
    if (p_70645_1_ != null)
    {
        this.motionX = (-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * 3.141593F / 180.0F) * 0.1F);
        this.motionZ = (-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * 3.141593F / 180.0F) * 0.1F);
    }
    else
    {
        this.motionX = (this.motionZ = 0.0D);
    }
    this.yOffset = 0.1F;
    addStat(StatList.deathsStat, 1);
}
项目:TombManyGraves    文件:TombManyGravesCommonEvents.java   
@SubscribeEvent
public void itemDrop(PlayerDropsEvent event)
{
    List<EntityItem> items = event.getDrops();
    for (EntityItem item : items)
    {
        if (item.getEntityItem().getItem() == ModItems.itemDeathList)
        {
            item.setDead();
        }
    }
}
项目:Alchemy    文件:CapabilityBauble.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerDrops(PlayerDropsEvent event) {
    EntityPlayer player = event.getEntityPlayer();
    if (!player.world.getGameRules().getBoolean("keepInventory")) {
        IInventory inventory = player.getCapability(AlchemyCapabilityLoader.bauble, null);
        if (inventory != null)
            for (int i = 0, len = inventory.getSizeInventory(); i < len; i++) {
                ItemStack item = inventory.removeStackFromSlot(i);
                if (!item.isEmpty())
                    event.getDrops().add(InventoryHelper.getEntityItem(player, item));
            }
    }
}
项目:geomastery    文件:PlayerEvents.java   
/** Adds yoke and backpack to player death drops. */
@SubscribeEvent
public void playerDrops(PlayerDropsEvent event) {

    EntityPlayer player = event.getEntityPlayer();
    ICapPlayer capPlayer = player.getCapability(GeoCaps.CAP_PLAYER, null);
    World world = player.world;
    double x = player.posX;
    double y = player.posY;
    double z = player.posZ;
    List<EntityItem> drops = event.getDrops();
    drops.add(new EntityItem(world, x, y, z, capPlayer.removeBackpack()));
    drops.add(new EntityItem(world, x, y, z, capPlayer.removeYoke()));
}
项目:Cyclic    文件:EventExtendedInventory.java   
@SubscribeEvent
public void playerDeath(PlayerDropsEvent event) {
  if (keepOnDeath == false) {
    World world = event.getEntityPlayer().getEntityWorld();
    if (!world.isRemote && world.getGameRules().getBoolean("keepInventory") == false) {
      //so config says dont keep it on death. AND the gamerule says dont keep as well
      UtilPlayerInventoryFilestorage.getPlayerInventory(event.getEntityPlayer()).dropItems(event.getDrops(), event.getEntityPlayer().getPosition());
    }
  }
}
项目:UHC-Reloaded    文件:ModdedGoldenStuff.java   
/** Make the player drop a skull. */
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent e) {
    e.getEntityPlayer().dropItem(
        Misc.getSkullFromOwner(e.getEntityPlayer().getGameProfile()), true,
        false);
}
项目:ComponentEquipment    文件:PersistanceEventHandler.java   
@SubscribeEvent
public void onPlayerDeath( PlayerDropsEvent event )
{
    NBTTagList persisted = new NBTTagList();

    List< EntityItem > items = event.drops;
    for ( int i = 0; i < items.size(); ++i )
    {
        EntityItem entity = items.get( i );
        ItemStack stack = entity.getEntityItem();
        if ( stack == null || !( stack.getItem() instanceof EquipmentItem ) )
        {
            continue;
        }

        EquipmentItem itemBase = ( EquipmentItem ) stack.getItem();
        int level = itemBase.equipment.getModifierLevel( stack, "persistance" );
        if ( ( level & PersistanceModifier.INVENTORY ) != 0 )
        {
            NBTTagCompound item = new NBTTagCompound();
            stack.writeToNBT( item );
            persisted.appendTag( item );

            items.remove( i ); --i;
            continue;
        }
    }

    if ( persisted.tagCount() > 0 )
    {
        NBTTagCompound tag = event.entityPlayer.getEntityData();
        NBTTagCompound persistant = tag.getCompoundTag( EntityPlayer.PERSISTED_NBT_TAG );

        persistant.setTag( PERSIST_TAG, persisted );

        tag.setTag( EntityPlayer.PERSISTED_NBT_TAG, persistant );
    }
}
项目:CcmBurialServicesInc    文件:EventHandler.java   
/**
 * For deaths
 */
@ForgeSubscribe(priority = EventPriority.HIGHEST)
public void deathEvent(PlayerDropsEvent event)
{
    World world = event.entityPlayer.getEntityWorld();
    if (world.isRemote) return;
    event.setCanceled(GraveHandler.onDeath(event.entityPlayer.worldObj, event.entityPlayer, event.drops));
}
项目:4Space-1.7    文件:EntityPlayer.java   
public void onDeath(DamageSource p_70645_1_)
{
    if (ForgeHooks.onLivingDeath(this, p_70645_1_)) {
        return;
    }
    super.onDeath(p_70645_1_);
    setSize(0.2F, 0.2F);
    setPosition(this.posX, this.posY, this.posZ);
    this.motionY = 0.1000000014901161D;

    this.captureDrops = true;
    this.capturedDrops.clear();
    if (getCommandSenderName().equals("Notch")) {
        func_146097_a(new ItemStack(Items.apple, 1), true, false);
    }
    if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
        this.inventory.dropAllItems();
    }
    this.captureDrops = false;
    if (!this.worldObj.isRemote)
    {
        PlayerDropsEvent event = new PlayerDropsEvent(this, p_70645_1_, this.capturedDrops, this.recentlyHit > 0);
        if (!MinecraftForge.EVENT_BUS.post(event)) {
            for (EntityItem item : this.capturedDrops) {
                joinEntityItemWithWorld(item);
            }
        }
    }
    if (p_70645_1_ != null)
    {
        this.motionX = (-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * 3.141593F / 180.0F) * 0.1F);
        this.motionZ = (-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * 3.141593F / 180.0F) * 0.1F);
    }
    else
    {
        this.motionX = (this.motionZ = 0.0D);
    }
    this.yOffset = 0.1F;
    addStat(StatList.deathsStat, 1);
}
项目:NausicaaMod    文件:NPlayerHandler.java   
@SubscribeEvent
public void playerDrops (PlayerDropsEvent evt)
{
    // After playerDeath event. Modifying saved data.
    NPlayerStats stats = playerStats.get(evt.entityPlayer.getPersistentID());

    stats.armor.dropItems(evt.drops);

    playerStats.put(evt.entityPlayer.getPersistentID(), stats);
}
项目:CosmeticArmor    文件:PlayerEventHandler.java   
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent event) {
    if (event.entity instanceof EntityPlayer &&
        !event.entity.worldObj.isRemote &&
        !event.entity.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory") &&
        CommonProxy.dropOnDeath) {

        PlayerHandler.getArmor(event.entityPlayer).dropItemsAt(event.drops, event.entityPlayer);
    }
}
项目:projectzulu1.7.10-pre-1.3a    文件:DeathGamerules.java   
private PlayerDropsEvent createPlayerDropEvent(EntityPlayer player, DamageSource damageSource,
        ArrayList<EntityItem> drops) {
    int recentlyHit;
    try {
        recentlyHit = ObfuscationHelper.getCatchableFieldFromReflection("field_70718_bc", EntityLivingBase.class,
                player, Integer.class);
    } catch (NoSuchFieldException e) {
        recentlyHit = ObfuscationHelper.getFieldFromReflection("recentlyHit", EntityLivingBase.class, player,
                Integer.class);
    }
    return new PlayerDropsEvent(player, damageSource, player.capturedDrops, recentlyHit > 0);
}
项目:RuneMagic    文件:EventHandlerEntity.java   
@SubscribeEvent
public void playerDeath(PlayerDropsEvent event) {
    if (event.entity instanceof EntityPlayer && !event.entity.worldObj.isRemote && !event.entity.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
        PlayerHandler.getPlayerBaubles(event.entityPlayer).dropItems(event.drops);
    }

}
项目:Recall-Stones    文件:EventsRecall.java   
@SubscribeEvent
public void PlayerDropsEvent(PlayerDropsEvent event) {
    if (event.getSource().getSourceOfDamage()!=null) {
        if (event.getSource().getSourceOfDamage() instanceof EntityPlayer) {
            //drop essence
            if (RecallItems.dropEssence) {
                EntityPlayer deadPlayer = event.getEntityPlayer();
                ItemPlayerEssence essence = RecallItems.itemPlayerEssence;
                ItemStack essenceStack = new ItemStack(essence);
                essence.setPlayer(essenceStack, deadPlayer);
                event.getEntity().entityDropItem(essenceStack, 0.5F);
            }
        }
    }
}
项目:IceAndShadow2    文件:NyxDeathSystem.java   
@SubscribeEvent
public void onDrop(PlayerDropsEvent e) {
    final boolean gr = e.entityPlayer.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory");
    if (!e.entityPlayer.worldObj.isRemote && e.entityPlayer.dimension == IaSFlags.dim_nyx_id && !gr) {
        e.setCanceled(true);
        NyxDeathSystem.plai_inv = NyxDeathSystem.determineRespawnInventory(NyxDeathSystem.plai_inv, true);
        e.entityPlayer.inventory.copyInventory(NyxDeathSystem.plai_inv);
        NyxDeathSystem.death_inv.put(e.entityPlayer.getEntityId(), e.entityPlayer.inventory);
    }
}
项目:Mini-Bosses    文件:MBEventHandler.java   
@SubscribeEvent
public void onPlayerDrops(PlayerDropsEvent event) {
    if(playersToSave.contains(event.entityPlayer)) {
        for(EntityItem drop : event.drops) {
            if(drop.getEntityItem().getItem() == MBItems.reviveHeart) {
                drop.setDead();
            }
            if(drop.getEntityItem().getItem() == MBItems.dodgeGem) {
                NBTHelper.writeIntToStack(drop.getEntityItem(), "ShortDespawn", 1);
            }
        }
        playersToSave.remove(event.entityPlayer);
    }
}
项目:projectzulu1.7.10    文件:DeathGamerules.java   
private PlayerDropsEvent createPlayerDropEvent(EntityPlayer player, DamageSource damageSource,
        ArrayList<EntityItem> drops) {
    int recentlyHit;
    try {
        recentlyHit = ObfuscationHelper.getCatchableFieldFromReflection("field_70718_bc", EntityLivingBase.class,
                player, Integer.class);
    } catch (NoSuchFieldException e) {
        recentlyHit = ObfuscationHelper.getFieldFromReflection("recentlyHit", EntityLivingBase.class, player,
                Integer.class);
    }
    return new PlayerDropsEvent(player, damageSource, player.capturedDrops, recentlyHit > 0);
}
项目:Dota2Items    文件:ItemTracker.java   
@ForgeSubscribe
public void onPlayerDrops(PlayerDropsEvent event) {
    if (event.entity.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
        // If "keepInventory" is turned on, the items will return to you anyway.
        return;
    }
    // Remember all the Dota 2 items the player had in inventory.
    // In case he logs out while dead, put them back into his inventory for storage.
    Iterator<EntityItem> iter = event.drops.iterator();
    List<ItemStack> list = retainedItems.get(event.entityPlayer);
    if (list == null) {
        list = new ArrayList<ItemStack>();
        retainedItems.put(event.entityPlayer, list);
    }
    while (iter.hasNext()) {
        EntityItem entityItem = iter.next();
        ItemStack stack = entityItem.getEntityItem();
        if (stack.getItem() instanceof Dota2Item) {
            Dota2Item dota2Item = (Dota2Item) stack.getItem();
            if (!dota2Item.getDropsOnDeath()) {
                iter.remove();
                list.add(stack.copy());
                event.entityPlayer.inventory.addItemStackToInventory(stack);
            }
        }
    }
}
项目:CrystalMod    文件:EventHandler.java   
@SubscribeEvent
public void playerDeath(PlayerDropsEvent event) {
    if (event.getEntity() instanceof EntityPlayer && !event.getEntity().getEntityWorld().isRemote) {
        boolean keepInv = event.getEntity().getEntityWorld().getGameRules().getBoolean("keepInventory");
        addPlayerHeads(event);
        if(!keepInv){
            ExtendedPlayer exPlayer = ExtendedPlayerProvider.getExtendedPlayer(event.getEntityPlayer()); 
            if(exPlayer !=null){
                ExtendedPlayerInventory inv = exPlayer.getInventory();

                ItemStack backpack = inv.getStackInSlot(ExtendedPlayerInventory.BACKPACK_SLOT_ID);

                boolean keepBackpack = false;
                if(ItemStackTools.isValid(backpack)){
                    InventoryBackpackUpgrades upgrades = BackpackUtil.getUpgradeInventory(event.getEntityPlayer(), backpack);
                    if(upgrades !=null && upgrades.hasUpgrade(BackpackUpgrade.DEATH)){
                        if(Config.backpackDeathUpgradeConsume){
                            int index = upgrades.getUpgradeIndex(BackpackUpgrade.DEATH);
                            if(index > -1){
                                upgrades.decrStackSize(index, 1);
                                upgrades.markDirty();
                                upgrades.guiSave(event.getEntityPlayer());
                                inv.setChanged(ExtendedPlayerInventory.BACKPACK_SLOT_ID, true);
                                keepBackpack = true;
                            }
                        } else keepBackpack = true;
                    }
                }

                for (int i = 0; i < inv.getSlots(); ++i) {
                    if (ItemStackTools.isValid(inv.getStackInSlot(i))) {
                        if(i == ExtendedPlayerInventory.BACKPACK_SLOT_ID){
                            if(keepBackpack){
                                continue;
                            }
                        }
                        event.getDrops().add(ItemUtil.dropFromPlayer(event.getEntityPlayer(), inv.getStackInSlot(i).copy(), true));
                        inv.setStackInSlot(i, ItemStackTools.getEmptyStack());
                    }
                }
            }           
        }
    }
}
项目:ServerForge    文件:PlayerDeathEvent.java   
public PlayerDeathEvent(PlayerDropsEvent playerDropsEvent){
    this.playerDropsEvent = playerDropsEvent;
    setCancelled(playerDropsEvent.isCanceled());
}
项目:ServerForge    文件:DefaultEventListener.java   
@SubscribeEvent
public void playerDropEvent(PlayerDropsEvent e){
    PlayerDeathEvent playerDeathEvent = new PlayerDeathEvent(e);
    eventManager.fireEvent(playerDeathEvent);
    e.setCanceled(playerDeathEvent.getCancelled());
}
项目:Cauldron    文件:EntityPlayer.java   
public void onDeath(DamageSource p_70645_1_)
{
    if (ForgeHooks.onLivingDeath(this, p_70645_1_)) return;
    super.onDeath(p_70645_1_);
    this.setSize(0.2F, 0.2F);
    this.setPosition(this.posX, this.posY, this.posZ);
    this.motionY = 0.10000000149011612D;

    captureDrops = true;
    capturedDrops.clear();

    if (this.getCommandSenderName().equals("Notch"))
    {
        this.func_146097_a(new ItemStack(Items.apple, 1), true, false);
    }

    if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
    {
        this.inventory.dropAllItems();
    }

    captureDrops = false;

    if (!worldObj.isRemote)
    {
        PlayerDropsEvent event = new PlayerDropsEvent(this, p_70645_1_, capturedDrops, recentlyHit > 0);
        if (!MinecraftForge.EVENT_BUS.post(event))
        {
            for (EntityItem item : capturedDrops)
            {
                joinEntityItemWithWorld(item);
            }
        }
    }

    if (p_70645_1_ != null)
    {
        this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F);
        this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F);
    }
    else
    {
        this.motionX = this.motionZ = 0.0D;
    }

    this.yOffset = 0.1F;
    this.addStat(StatList.deathsStat, 1);
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void onDeath(DamageSource p_70645_1_)
{
    if (ForgeHooks.onLivingDeath(this, p_70645_1_)) return;
    this.mcServer.getConfigurationManager().sendChatMsg(this.func_110142_aN().func_151521_b());

    if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
    {
        captureDrops = true;
        capturedDrops.clear();

        this.inventory.dropAllItems();

        captureDrops = false;
        PlayerDropsEvent event = new PlayerDropsEvent(this, p_70645_1_, capturedDrops, recentlyHit > 0);
        if (!MinecraftForge.EVENT_BUS.post(event))
        {
            for (EntityItem item : capturedDrops)
            {
                joinEntityItemWithWorld(item);
            }
        }
    }

    Collection collection = this.worldObj.getScoreboard().func_96520_a(IScoreObjectiveCriteria.deathCount);
    Iterator iterator = collection.iterator();

    while (iterator.hasNext())
    {
        ScoreObjective scoreobjective = (ScoreObjective)iterator.next();
        Score score = this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective);
        score.func_96648_a();
    }

    EntityLivingBase entitylivingbase = this.func_94060_bK();

    if (entitylivingbase != null)
    {
        int i = EntityList.getEntityID(entitylivingbase);
        EntityList.EntityEggInfo entityegginfo = (EntityList.EntityEggInfo)EntityList.entityEggs.get(Integer.valueOf(i));

        if (entityegginfo != null)
        {
            this.addStat(entityegginfo.field_151513_e, 1);
        }

        entitylivingbase.addToPlayerScore(this, this.scoreValue);
    }

    this.addStat(StatList.deathsStat, 1);
    this.func_110142_aN().func_94549_h();
}
项目:Cauldron    文件:EntityPlayer.java   
public void onDeath(DamageSource p_70645_1_)
{
    if (ForgeHooks.onLivingDeath(this, p_70645_1_)) return;
    super.onDeath(p_70645_1_);
    this.setSize(0.2F, 0.2F);
    this.setPosition(this.posX, this.posY, this.posZ);
    this.motionY = 0.10000000149011612D;

    captureDrops = true;
    capturedDrops.clear();

    if (this.getCommandSenderName().equals("Notch"))
    {
        this.func_146097_a(new ItemStack(Items.apple, 1), true, false);
    }

    if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
    {
        this.inventory.dropAllItems();
    }

    captureDrops = false;

    if (!worldObj.isRemote)
    {
        PlayerDropsEvent event = new PlayerDropsEvent(this, p_70645_1_, capturedDrops, recentlyHit > 0);
        if (!MinecraftForge.EVENT_BUS.post(event))
        {
            for (EntityItem item : capturedDrops)
            {
                joinEntityItemWithWorld(item);
            }
        }
    }

    if (p_70645_1_ != null)
    {
        this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F);
        this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F);
    }
    else
    {
        this.motionX = this.motionZ = 0.0D;
    }

    this.yOffset = 0.1F;
    this.addStat(StatList.deathsStat, 1);
}
项目:RuneCraftery    文件:EntityPlayerMP.java   
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource par1DamageSource)
{
    if (ForgeHooks.onLivingDeath(this, par1DamageSource)) return;
    this.mcServer.getConfigurationManager().sendChatMsg(this.func_110142_aN().func_94546_b());

    if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
    {
        captureDrops = true;
        capturedDrops.clear();

        this.inventory.dropAllItems();

        captureDrops = false;
        PlayerDropsEvent event = new PlayerDropsEvent(this, par1DamageSource, capturedDrops, recentlyHit > 0);
        if (!MinecraftForge.EVENT_BUS.post(event))
        {
            for (EntityItem item : capturedDrops)
            {
                joinEntityItemWithWorld(item);
            }
        }
    }

    Collection collection = this.worldObj.getScoreboard().func_96520_a(ScoreObjectiveCriteria.deathCount);
    Iterator iterator = collection.iterator();

    while (iterator.hasNext())
    {
        ScoreObjective scoreobjective = (ScoreObjective)iterator.next();
        Score score = this.getWorldScoreboard().func_96529_a(this.getEntityName(), scoreobjective);
        score.func_96648_a();
    }

    EntityLivingBase entitylivingbase = this.func_94060_bK();

    if (entitylivingbase != null)
    {
        entitylivingbase.addToPlayerScore(this, this.scoreValue);
    }

    this.addStat(StatList.deathsStat, 1);
}
项目:RuneCraftery    文件:EntityPlayer.java   
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource par1DamageSource)
{
    if (ForgeHooks.onLivingDeath(this, par1DamageSource)) return;
    super.onDeath(par1DamageSource);
    this.setSize(0.2F, 0.2F);
    this.setPosition(this.posX, this.posY, this.posZ);
    this.motionY = 0.10000000149011612D;

    captureDrops = true;
    capturedDrops.clear();

    if (this.username.equals("Notch"))
    {
        this.dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true);
    }

    if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
    {
        this.inventory.dropAllItems();
    }

    captureDrops = false;

    if (!worldObj.isRemote)
    {
        PlayerDropsEvent event = new PlayerDropsEvent(this, par1DamageSource, capturedDrops, recentlyHit > 0);
        if (!MinecraftForge.EVENT_BUS.post(event))
        {
            for (EntityItem item : capturedDrops)
            {
                joinEntityItemWithWorld(item);
            }
        }
    }

    if (par1DamageSource != null)
    {
        this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F);
        this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F);
    }
    else
    {
        this.motionX = this.motionZ = 0.0D;
    }

    this.yOffset = 0.1F;
    this.addStat(StatList.deathsStat, 1);
}
项目:BetterNutritionMod    文件:EntityPlayerMP.java   
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource par1DamageSource)
{
    if (ForgeHooks.onLivingDeath(this, par1DamageSource)) return;
    this.mcServer.getConfigurationManager().sendChatMsg(this.func_110142_aN().func_94546_b());

    if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
    {
        captureDrops = true;
        capturedDrops.clear();

        this.inventory.dropAllItems();

        captureDrops = false;
        PlayerDropsEvent event = new PlayerDropsEvent(this, par1DamageSource, capturedDrops, recentlyHit > 0);
        if (!MinecraftForge.EVENT_BUS.post(event))
        {
            for (EntityItem item : capturedDrops)
            {
                joinEntityItemWithWorld(item);
            }
        }
    }

    Collection collection = this.worldObj.getScoreboard().func_96520_a(ScoreObjectiveCriteria.deathCount);
    Iterator iterator = collection.iterator();

    while (iterator.hasNext())
    {
        ScoreObjective scoreobjective = (ScoreObjective)iterator.next();
        Score score = this.getWorldScoreboard().func_96529_a(this.getEntityName(), scoreobjective);
        score.func_96648_a();
    }

    EntityLivingBase entitylivingbase = this.func_94060_bK();

    if (entitylivingbase != null)
    {
        entitylivingbase.addToPlayerScore(this, this.scoreValue);
    }

    this.addStat(StatList.deathsStat, 1);
}
项目:BetterNutritionMod    文件:EntityPlayer.java   
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource par1DamageSource)
{
    if (ForgeHooks.onLivingDeath(this, par1DamageSource)) return;
    super.onDeath(par1DamageSource);
    this.setSize(0.2F, 0.2F);
    this.setPosition(this.posX, this.posY, this.posZ);
    this.motionY = 0.10000000149011612D;

    captureDrops = true;
    capturedDrops.clear();

    if (this.username.equals("Notch"))
    {
        this.dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true);
    }

    if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
    {
        this.inventory.dropAllItems();
    }

    captureDrops = false;

    if (!worldObj.isRemote)
    {
        PlayerDropsEvent event = new PlayerDropsEvent(this, par1DamageSource, capturedDrops, recentlyHit > 0);
        if (!MinecraftForge.EVENT_BUS.post(event))
        {
            for (EntityItem item : capturedDrops)
            {
                joinEntityItemWithWorld(item);
            }
        }
    }

    if (par1DamageSource != null)
    {
        this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F);
        this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F);
    }
    else
    {
        this.motionX = this.motionZ = 0.0D;
    }

    this.yOffset = 0.1F;
    this.addStat(StatList.deathsStat, 1);
}