2015-03-07 12:51:28 +01:00
|
|
|
package ellpeck.actuallyadditions.event;
|
2015-03-07 02:23:31 +01:00
|
|
|
|
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
2015-03-07 12:51:28 +01:00
|
|
|
import ellpeck.actuallyadditions.items.InitItems;
|
|
|
|
import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops;
|
2015-03-07 02:23:31 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
2015-07-02 19:03:44 +02:00
|
|
|
public class LivingDropEvent{
|
2015-03-29 15:29:05 +02:00
|
|
|
|
2015-03-07 02:23:31 +01:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onEntityDropEvent(LivingDropsEvent event){
|
|
|
|
if(event.source.getEntity() instanceof EntityPlayer){
|
|
|
|
for(int i = 0; i < TheSpecialDrops.values().length; i++){
|
|
|
|
TheSpecialDrops theDrop = TheSpecialDrops.values()[i];
|
2015-03-29 15:29:05 +02:00
|
|
|
if(theDrop.canDrop && theDrop.dropFrom.isAssignableFrom(event.entityLiving.getClass())){
|
2015-03-07 02:23:31 +01:00
|
|
|
if(new Random().nextInt(100) + 1 <= theDrop.chance){
|
|
|
|
event.entityLiving.entityDropItem(new ItemStack(InitItems.itemSpecialDrop, new Random().nextInt(theDrop.maxAmount) + 1, theDrop.ordinal()), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|