Call Looting Event on player death and loot table drops (#3275)

* Call Looting Event on player death and loot table drops

* Simplify patches

* More code cleanup: Replace old usage with compact forgehooks implementation
This commit is contained in:
boni authored and cpw committed 2016-10-30 10:53:50 -05:00
1 parent 858056c089
commit 5f9034d95b
6 files changed
+64 -13

No files matched your search

@@ -43,6 +43,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
@@ -518,7 +519,22 @@ public class ForgeHooks
return (MinecraftForge.EVENT_BUS.post(event) ? null : new float[]{event.getDistance(), event.getDamageMultiplier()});
}
public static int getLootingLevel(EntityLivingBase target, DamageSource cause, int level) {
public static int getLootingLevel(Entity target, Entity killer, DamageSource cause)
{
int looting = 0;
if (killer instanceof EntityLivingBase)
{
looting = EnchantmentHelper.getLootingModifier((EntityLivingBase)killer);
}
if (target instanceof EntityLivingBase)
{
looting = getLootingLevel((EntityLivingBase)target, cause, looting);
}
return looting;
}
public static int getLootingLevel(EntityLivingBase target, DamageSource cause, int level)
{
LootingLevelEvent event = new LootingLevelEvent(target, cause, level);
MinecraftForge.EVENT_BUS.post(event);
return event.getLootingLevel();