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

修复爆炸

This commit is contained in:
XiaoMoMi
2025-07-05 02:13:35 +08:00
parent f7429eaed7
commit c0ba2392ee
5 changed files with 17 additions and 3 deletions

View File

@@ -188,7 +188,7 @@ public class UnsafeCompositeBlockBehavior extends BukkitBlockBehavior {
}
@Override
public void onExplosionHit(Object thisBlock, Object[] args, Callable<Object> superMethod) {
public void onExplosionHit(Object thisBlock, Object[] args, Callable<Object> superMethod) throws Exception {
for (AbstractBlockBehavior behavior : this.behaviors) {
behavior.onExplosionHit(thisBlock, args, superMethod);
}

View File

@@ -148,7 +148,7 @@ public final class BlockGenerator {
// onExplosionHit 1.21+
.method(ElementMatchers.returns(void.class)
.and(ElementMatchers.takesArgument(0, CoreReflections.clazz$BlockState))
.and(ElementMatchers.takesArgument(1, CoreReflections.clazz$ServerLevel))
.and(ElementMatchers.takesArgument(1, VersionHelper.isOrAbove1_21_2() ? CoreReflections.clazz$ServerLevel : CoreReflections.clazz$Level))
.and(ElementMatchers.takesArgument(2, CoreReflections.clazz$BlockPos))
.and(ElementMatchers.takesArgument(3, CoreReflections.clazz$Explosion))
.and(ElementMatchers.takesArgument(4, BiConsumer.class))
@@ -501,6 +501,7 @@ public final class BlockGenerator {
ObjectHolder<BlockBehavior> holder = ((DelegatingBlock) thisObj).behaviorDelegate();
try {
holder.value().onExplosionHit(thisObj, args, superMethod);
superMethod.call();
} catch (Exception e) {
CraftEngine.instance().logger().severe("Failed to run onExplosionHit", e);
}

View File

@@ -100,6 +100,9 @@ public final class BlockStateGenerator {
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);
if (!CoreReflections.clazz$Player.isInstance(optionalPlayer)) {
optionalPlayer = null;
}
// do not drop if it's not the correct tool
BlockSettings settings = state.settings();