mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 11:59:25 +00:00
Fix not dropping xp for player sourced explosions and various other cases when xp should drop (#9588)
This commit is contained in:
1 parent
f1939ef144
commit
45e27c62e9
4 files changed
+45
-1
No files matched your search
@@ -87,6 +87,7 @@ import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
@@ -477,6 +478,15 @@ public class ForgeHooks
|
||||
return ichat;
|
||||
}
|
||||
|
||||
public static void dropXpForBlock(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack)
|
||||
{
|
||||
int fortuneLevel = stack.getEnchantmentLevel(Enchantments.BLOCK_FORTUNE);
|
||||
int silkTouchLevel = stack.getEnchantmentLevel(Enchantments.SILK_TOUCH);
|
||||
int exp = state.getExpDrop(level, level.random, pos, fortuneLevel, silkTouchLevel);
|
||||
if (exp > 0)
|
||||
state.getBlock().popExperience(level, pos, exp);
|
||||
}
|
||||
|
||||
public static int onBlockBreakEvent(Level level, GameType gameType, ServerPlayer entityPlayer, BlockPos pos)
|
||||
{
|
||||
// Logic from tryHarvestBlock for pre-canceling the event
|
||||
|
||||
Reference in new issue
Block a user