mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-26 23:13:15 +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
@@ -32,6 +32,22 @@
|
||||
} else if (blockstate.m_60815_()) {
|
||||
Block.BlockStatePairKey block$blockstatepairkey = new Block.BlockStatePairKey(p_152445_, blockstate, p_152448_);
|
||||
Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey> object2bytelinkedopenhashmap = f_49789_.get();
|
||||
@@ -276,11 +_,14 @@
|
||||
}
|
||||
|
||||
public static void m_49881_(BlockState p_49882_, Level p_49883_, BlockPos p_49884_, @Nullable BlockEntity p_49885_, @Nullable Entity p_49886_, ItemStack p_49887_) {
|
||||
+ dropResources(p_49882_, p_49883_, p_49884_, p_49885_, p_49886_, p_49887_, true);
|
||||
+ }
|
||||
+ public static void dropResources(BlockState p_49882_, Level p_49883_, BlockPos p_49884_, @Nullable BlockEntity p_49885_, @Nullable Entity p_49886_, ItemStack p_49887_, boolean dropXp) {
|
||||
if (p_49883_ instanceof ServerLevel) {
|
||||
m_49874_(p_49882_, (ServerLevel)p_49883_, p_49884_, p_49885_, p_49886_, p_49887_).forEach((p_49944_) -> {
|
||||
m_49840_(p_49883_, p_49884_, p_49944_);
|
||||
});
|
||||
- p_49882_.m_222967_((ServerLevel)p_49883_, p_49884_, p_49887_, true);
|
||||
+ p_49882_.m_222967_((ServerLevel)p_49883_, p_49884_, p_49887_, dropXp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -313,7 +_,7 @@
|
||||
}
|
||||
|
||||
@@ -56,6 +72,16 @@
|
||||
public float m_7325_() {
|
||||
return this.f_60444_;
|
||||
}
|
||||
@@ -345,7 +_,8 @@
|
||||
public void m_6240_(Level p_49827_, Player p_49828_, BlockPos p_49829_, BlockState p_49830_, @Nullable BlockEntity p_49831_, ItemStack p_49832_) {
|
||||
p_49828_.m_36246_(Stats.f_12949_.m_12902_(this));
|
||||
p_49828_.m_36399_(0.005F);
|
||||
- m_49881_(p_49830_, p_49827_, p_49829_, p_49831_, p_49828_, p_49832_);
|
||||
+ //Forge: Don't drop xp as part of the resources as it is handled by the patches in ServerPlayerGameMode#destroyBlock
|
||||
+ dropResources(p_49830_, p_49827_, p_49829_, p_49831_, p_49828_, p_49832_, false);
|
||||
}
|
||||
|
||||
public void m_6402_(Level p_49847_, BlockPos p_49848_, BlockState p_49849_, @Nullable LivingEntity p_49850_, ItemStack p_49851_) {
|
||||
@@ -373,8 +_,10 @@
|
||||
|
||||
public void m_5548_(BlockGetter p_49821_, Entity p_49822_) {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
p_60516_.m_46747_(p_60517_);
|
||||
}
|
||||
|
||||
@@ -355,8 +_,8 @@
|
||||
@@ -355,14 +_,15 @@
|
||||
if (f == -1.0F) {
|
||||
return 0.0F;
|
||||
} else {
|
||||
@@ -38,6 +38,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
public void m_213646_(BlockState p_222949_, ServerLevel p_222950_, BlockPos p_222951_, ItemStack p_222952_, boolean p_222953_) {
|
||||
+ if (p_222953_) net.minecraftforge.common.ForgeHooks.dropXpForBlock(p_222949_, p_222950_, p_222951_, p_222952_);
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@@ -389,8 +_,7 @@
|
||||
|
||||
public final ResourceLocation m_60589_() {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -90,6 +90,7 @@ net/minecraft/world/item/crafting/RecipeManager.fromJson(Lnet/minecraft/resource
|
||||
net/minecraft/world/item/enchantment/EnchantmentHelper.getTagEnchantmentLevel(Lnet/minecraft/world/item/enchantment/Enchantment;Lnet/minecraft/world/item/ItemStack;)I=|p_44844_,p_44845_
|
||||
net/minecraft/world/level/Level.markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V=|p_46605_,levelchunk,blockstate,p_46606_,p_46607_,p_46608_
|
||||
net/minecraft/world/level/LevelSettings.<init>(Ljava/lang/String;Lnet/minecraft/world/level/GameType;ZLnet/minecraft/world/Difficulty;ZLnet/minecraft/world/level/GameRules;Lnet/minecraft/world/level/WorldDataConfiguration;Lcom/mojang/serialization/Lifecycle;)V=|p_250485_,p_250207_,p_251631_,p_252122_,p_248961_,p_248536_,p_249797_,lifecycle
|
||||
net/minecraft/world/level/block/Block.dropResources(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/item/ItemStack;Z)V=|p_49882_,p_49883_,p_49884_,p_49885_,p_49886_,p_49887_,dropXp
|
||||
net/minecraft/world/level/block/ConcretePowderBlock.shouldSolidify(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/material/FluidState;)Z=|p_52081_,p_52082_,p_52083_,fluidState
|
||||
net/minecraft/world/level/block/ConcretePowderBlock.touchesLiquid(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z=|p_52065_,p_52066_,state
|
||||
net/minecraft/world/level/block/FireBlock.tryCatchFire(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;ILnet/minecraft/util/RandomSource;ILnet/minecraft/core/Direction;)V=|p_53432_,p_53433_,p_53434_,p_53435_,p_53436_,face
|
||||
|
||||
Reference in new issue
Block a user