mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Provide damage source context to Item#onDestroyed(ItemEntity) (#8473)
This commit is contained in:
1 parent
e225dbc8d1
commit
edbc07ed22
5 files changed
+50
-2
No files matched your search
@@ -27,6 +27,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -673,6 +674,17 @@ public interface IForgeItem
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item entity for this stack is destroyed. Note: The {@link ItemStack} can be retrieved from the item entity.
|
||||
*
|
||||
* @param itemEntity The item entity that was destroyed.
|
||||
* @param damageSource Damage source that caused the item entity to "die".
|
||||
*/
|
||||
default void onDestroyed(ItemEntity itemEntity, DamageSource damageSource)
|
||||
{
|
||||
self().onDestroyed(itemEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this Item can be used to hide player head for enderman.
|
||||
*
|
||||
|
||||
@@ -22,6 +22,7 @@ package net.minecraftforge.common.extensions;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.monster.EnderMan;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.block.state.pattern.BlockInWorld;
|
||||
@@ -283,6 +284,17 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundTag>
|
||||
self().getItem().onHorseArmorTick(self(), world, horse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item entity for this stack is destroyed.
|
||||
*
|
||||
* @param itemEntity The item entity that was destroyed.
|
||||
* @param damageSource Damage source that caused the item entity to "die".
|
||||
*/
|
||||
default void onDestroyed(ItemEntity itemEntity, DamageSource damageSource)
|
||||
{
|
||||
self().getItem().onDestroyed(itemEntity, damageSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the specific ItemStack can be placed in the specified armor
|
||||
* slot, for the entity.
|
||||
|
||||
Reference in new issue
Block a user