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

32 lines
1.3 KiB
Java
Raw Normal View History

2015-05-07 16:36:29 +02:00
package ellpeck.actuallyadditions.event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.items.InitItems;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import java.util.Random;
public class EntityLivingEvent{
@SubscribeEvent
public void livingUpdateEvent(LivingUpdateEvent event){
if(!event.entityLiving.worldObj.isRemote){
if(event.entityLiving instanceof EntityOcelot){
EntityOcelot theOcelot = (EntityOcelot)event.entityLiving;
if(ConfigBoolValues.DO_CAT_DROPS.isEnabled() && theOcelot.isTamed()){
if(new Random().nextInt(ConfigIntValues.CAT_DROP_CHANCE.getValue())+1 == 1){
EntityItem item = new EntityItem(theOcelot.worldObj, theOcelot.posX + 0.5, theOcelot.posY + 0.5, theOcelot.posZ + 0.5, new ItemStack(InitItems.itemHairyBall));
theOcelot.worldObj.spawnEntityInWorld(item);
}
}
}
}
}
}