9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-19 23:19:15 +00:00

修复掉落物处理

This commit is contained in:
XiaoMoMi
2025-06-28 20:38:09 +08:00
parent 5db64d24cc
commit cbecd0d9d5
3 changed files with 7 additions and 5 deletions

View File

@@ -182,7 +182,6 @@ public final class BukkitCustomBlock extends AbstractCustomBlock {
if (settings.burnable()) {
CoreReflections.method$FireBlock$setFlammable.invoke(MBlocks.FIRE, nmsBlock, settings.burnChance(), settings.fireSpreadChance());
}
CoreReflections.field$BlockStateBase$requiresCorrectToolForDrops.set(nmsState, settings.requireCorrectTool());
}
} catch (Exception e) {
CraftEngine.instance().logger().warn("Failed to init block settings", e);

View File

@@ -98,13 +98,13 @@ public final class BlockStateGenerator {
if (vec3 == null) return List.of();
Object tool = FastNMS.INSTANCE.method$LootParams$Builder$getOptionalParameter(builder, MLootContextParams.TOOL);
Item<ItemStack> item = BukkitItemManager.instance().wrap(tool == null || FastNMS.INSTANCE.method$ItemStack$isEmpty(tool) ? null : FastNMS.INSTANCE.method$CraftItemStack$asCraftMirror(tool));
Object optionalPlayer = FastNMS.INSTANCE.method$LootParams$Builder$getOptionalParameter(builder, MLootContextParams.THIS_ENTITY);
// do not drop if it's not the correct tool
BlockSettings settings = state.settings();
if (settings.requireCorrectTool()) {
if (tool == null) return List.of();
if (optionalPlayer != null && settings.requireCorrectTool()) {
if (item == null) return List.of();
if (!settings.isCorrectTool(item.id()) &&
(!settings.respectToolComponent() || !FastNMS.INSTANCE.method$ItemStack$isCorrectToolForDrops(tool, state.customBlockState().handle()))) {
return List.of();
@@ -118,7 +118,7 @@ public final class BlockStateGenerator {
if (item != null) {
lootBuilder.withParameter(DirectContextParameters.ITEM_IN_HAND, item);
}
Object optionalPlayer = FastNMS.INSTANCE.method$LootParams$Builder$getOptionalParameter(builder, MLootContextParams.THIS_ENTITY);
BukkitServerPlayer player = optionalPlayer != null ? BukkitCraftEngine.instance().adapt(FastNMS.INSTANCE.method$ServerPlayer$getBukkitEntity(optionalPlayer)) : null;
Float radius = (Float) FastNMS.INSTANCE.method$LootParams$Builder$getOptionalParameter(builder, MLootContextParams.EXPLOSION_RADIUS);
if (radius != null) {

View File

@@ -67,6 +67,9 @@ items#misc:
template:
- default:pickaxe_power/level_4
overrides:
tags:
- minecraft:mineable/pickaxe
- minecraft:anvil
sounds:
break: minecraft:block.anvil.break
step: minecraft:block.anvil.step