mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 19:59:42 +00:00
Add an event that allows to modify the looting level based on damage source
This commit is contained in:
1 parent
f58d1cae1a
commit
432e3ab08a
4 files changed
+52
-1
No files matched your search
@@ -109,6 +109,7 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
|
||||
import net.minecraftforge.event.entity.living.LootingLevelEvent;
|
||||
import net.minecraftforge.event.entity.player.AnvilRepairEvent;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
@@ -515,6 +516,12 @@ 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) {
|
||||
LootingLevelEvent event = new LootingLevelEvent(target, cause, level);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getLootingLevel();
|
||||
}
|
||||
|
||||
public static boolean isLivingOnLadder(IBlockState state, World world, BlockPos pos, EntityLivingBase entity)
|
||||
{
|
||||
boolean isSpectator = (entity instanceof EntityPlayer && ((EntityPlayer)entity).isSpectator());
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.minecraftforge.event.entity.living;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
public class LootingLevelEvent extends LivingEvent {
|
||||
|
||||
private final DamageSource damageSource;
|
||||
|
||||
private int lootingLevel;
|
||||
|
||||
public LootingLevelEvent(EntityLivingBase entity, DamageSource damageSource, int lootingLevel) {
|
||||
super(entity);
|
||||
this.damageSource = damageSource;
|
||||
this.lootingLevel = lootingLevel;
|
||||
}
|
||||
|
||||
public DamageSource getDamageSource() {
|
||||
return damageSource;
|
||||
}
|
||||
|
||||
public int getLootingLevel() {
|
||||
return lootingLevel;
|
||||
}
|
||||
|
||||
public void setLootingLevel(int lootingLevel) {
|
||||
this.lootingLevel = lootingLevel;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user