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

54 lines
2.4 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
2016-05-16 22:52:27 +02:00
* This file ("LivingDropEvent.java") is part of the Actually Additions mod for Minecraft.
2015-08-29 14:33:25 +02:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.event;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.entity.EntityCreature;
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;
2016-01-07 18:20:59 +01:00
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
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){
2016-04-20 21:39:03 +02:00
if(event.getSource().getEntity() instanceof EntityPlayer){
//Drop Solidified XP
2016-04-20 21:39:03 +02:00
if(event.getEntityLiving() instanceof EntityCreature){
if(Util.RANDOM.nextInt(10) <= event.getLootingLevel()*2){
event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemSolidifiedExperience, Util.RANDOM.nextInt(2+event.getLootingLevel())+1), 0);
}
}
2015-07-17 07:38:55 +02:00
//Drop Cobwebs from Spiders
2016-04-20 21:39:03 +02:00
if(ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.getEntityLiving() instanceof EntitySpider){
if(Util.RANDOM.nextInt(20) <= event.getLootingLevel()*2){
event.getEntityLiving().entityDropItem(new ItemStack(Blocks.WEB, Util.RANDOM.nextInt(2+event.getLootingLevel())+1), 0);
2015-07-17 07:38:55 +02:00
}
}
2015-07-17 11:17:55 +02:00
//Drop Wings from Bats
2016-04-20 21:39:03 +02:00
if(ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof EntityBat){
if(Util.RANDOM.nextInt(15) <= event.getLootingLevel()*2){
event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemMisc, Util.RANDOM.nextInt(2+event.getLootingLevel())+1, TheMiscItems.BAT_WING.ordinal()), 0);
2015-07-17 11:17:55 +02:00
}
}
}
}
}