001package net.minecraftforge.event.entity.player; 002 003import java.util.ArrayList; 004 005import net.minecraft.enchantment.EnchantmentHelper; 006import net.minecraft.entity.item.EntityItem; 007import net.minecraft.entity.player.EntityPlayer; 008import net.minecraft.util.DamageSource; 009import net.minecraftforge.event.Cancelable; 010import net.minecraftforge.event.entity.living.LivingDropsEvent; 011 012/** 013 * Child class of LivingDropEvent that is fired specifically when a 014 * player dies. Canceling the event will prevent ALL drops from entering the 015 * world. 016 */ 017@Cancelable 018public class PlayerDropsEvent extends LivingDropsEvent 019{ 020 public final EntityPlayer entityPlayer; 021 022 /** 023 * Creates a new event containing all the items that will drop into the 024 * world when a player dies. 025 * @param entity The dying player. 026 * @param source The source of the damage which is killing the player. 027 * @param drops List of all drops entering the world. 028 */ 029 public PlayerDropsEvent(EntityPlayer entity, DamageSource source, ArrayList<EntityItem> drops, boolean recentlyHit) 030 { 031 super(entity, source, drops, 032 (source.getEntity() instanceof EntityPlayer) ? 033 EnchantmentHelper.getLootingModifier(((EntityPlayer)source.getEntity())) : 0, 034 recentlyHit, 0); 035 036 this.entityPlayer = entity; 037 } 038}