1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package me.km.effects.passive;
- import me.km.KajetansMod;
- import me.km.api.Module;
- import me.km.api.ModuleListener;
- import me.km.api.Utils;
- import me.km.effects.Effect;
- import me.km.effects.EffectUtils;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.item.EntityItem;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraftforge.event.entity.living.LivingDropsEvent;
- import net.minecraftforge.event.entity.living.LivingExperienceDropEvent;
- import net.minecraftforge.fml.common.eventhandler.EventPriority;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- public class EntityDrop extends ModuleListener
- {
- public EntityDrop(Module m)
- {
- super(m);
- }
-
- // low, due to changes with SnuviScript
- @SubscribeEvent(priority = EventPriority.LOW)
- public void onEntityDrop(LivingDropsEvent e)
- {
- if(!KajetansMod.worldManager.getWorldPreferences(e.getEntityLiving().world).skills)
- {
- return;
- }
- Entity killer = e.getSource().getImmediateSource();
- if(killer == null || !(killer instanceof EntityPlayer))
- {
- return;
- }
- EntityPlayer p = (EntityPlayer) killer;
- int drops = EffectUtils.getEffectLevel(p, Effect.MORE_DROPS);
- if(drops >= 1)
- {
- int random;
- for(EntityItem item : e.getDrops())
- {
- random = Utils.randomInt(-2, drops);
- if(random >= 1)
- {
- item.getItem().grow(random);
- }
- }
- }
- }
-
- // low, due to changes with SnuviScript
- @SubscribeEvent(priority = EventPriority.LOW)
- public void onEntityDropXp(LivingExperienceDropEvent e)
- {
- if(!KajetansMod.worldManager.getWorldPreferences(e.getEntityLiving().world).skills)
- {
- return;
- }
- EntityPlayer p = e.getAttackingPlayer();
- if(p == null)
- {
- return;
- }
- int xp = EffectUtils.getEffectLevel(p, Effect.XP_COLLECTOR);
- if(xp >= 1)
- {
- int i = e.getOriginalExperience();
- i *= 1 + xp / 5f;
- e.setDroppedExperience(i);
- }
- }
- }
|