Skip to content

Commit

Permalink
Seems arrows fired by non-players have the arrow entity for both
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Dec 17, 2022
1 parent d8fbac1 commit c007fb8
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,13 @@ private static void onLooting(LootingLevelEvent event) {
Entity direct = damageSource.getDirectEntity();
int level = event.getLootingLevel();
LivingEntity target = event.getEntityLiving();
if (direct != source) {
if (direct instanceof AbstractArrow) {
// need to build a context from the relevant capabilities to use the modifier
ModifierNBT modifiers = direct.getCapability(EntityModifierCapability.CAPABILITY).orElse(EntityModifierCapability.EMPTY).getModifiers();
if (!modifiers.isEmpty()) {
ModDataNBT persistentData = direct.getCapability(PersistentDataCapability.CAPABILITY).map(ModDataNBT::new).orElseGet(ModDataNBT::new);
DummyToolStack tool = new DummyToolStack(Items.AIR, modifiers, persistentData);
level = LootingModifierHook.getLootingValue(TinkerHooks.PROJECTILE_LOOTING, tool, holder, target, damageSource, 0);
}
if (direct instanceof AbstractArrow) {
// need to build a context from the relevant capabilities to use the modifier
ModifierNBT modifiers = EntityModifierCapability.getOrEmpty(direct);
if (!modifiers.isEmpty()) {
ModDataNBT persistentData = direct.getCapability(PersistentDataCapability.CAPABILITY).map(ModDataNBT::new).orElseGet(ModDataNBT::new);
DummyToolStack tool = new DummyToolStack(Items.AIR, modifiers, persistentData);
level = LootingModifierHook.getLootingValue(TinkerHooks.PROJECTILE_LOOTING, tool, holder, target, damageSource, 0);
}
} else {
// not an arrow? means the held tool is to blame
Expand Down

0 comments on commit c007fb8

Please sign in to comment.