ActuallyAdditions/src/main/java/ellpeck/actuallyadditions/event/LivingDropEvent.java

49 lines
2.3 KiB
Java
Raw Normal View History

2015-03-07 12:51:28 +01:00
package ellpeck.actuallyadditions.event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
2015-07-17 07:38:55 +02:00
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
2015-03-07 12:51:28 +01:00
import ellpeck.actuallyadditions.items.InitItems;
2015-07-17 11:17:55 +02:00
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
2015-03-07 12:51:28 +01:00
import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops;
2015-07-17 07:38:55 +02:00
import net.minecraft.entity.monster.EntitySpider;
2015-07-17 11:17:55 +02:00
import net.minecraft.entity.passive.EntityBat;
import net.minecraft.entity.player.EntityPlayer;
2015-07-17 07:38:55 +02:00
import net.minecraft.init.Blocks;
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
@SubscribeEvent
public void onEntityDropEvent(LivingDropsEvent event){
if(event.source.getEntity() instanceof EntityPlayer){
2015-07-17 07:38:55 +02:00
//Drop Special Items (Solidified Experience, Pearl Shards etc.)
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())){
if(new Random().nextInt(100) + 1 <= theDrop.chance){
event.entityLiving.entityDropItem(new ItemStack(InitItems.itemSpecialDrop, new Random().nextInt(theDrop.maxAmount) + 1, theDrop.ordinal()), 0);
}
}
}
2015-07-17 07:38:55 +02:00
//Drop Cobwebs from Spiders
if(ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.entityLiving instanceof EntitySpider){
if(new Random().nextInt(ConfigIntValues.SPIDER_DROP_CHANCE.getValue()) <= 0){
event.entityLiving.entityDropItem(new ItemStack(Blocks.web, new Random().nextInt(2)+1), 0);
}
}
2015-07-17 11:17:55 +02:00
//Drop Wings from Bats
if(ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.entityLiving instanceof EntityBat){
if(new Random().nextInt(ConfigIntValues.BAT_DROP_CHANCE.getValue()) <= 0){
event.entityLiving.entityDropItem(new ItemStack(InitItems.itemMisc, new Random().nextInt(2)+1, TheMiscItems.BAT_WING.ordinal()), 0);
}
}
}
}
}