From a9ea98867bb8109313e09c66be00d3fa435b012d Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Sun, 3 Nov 2024 22:03:40 +0800 Subject: [PATCH] Fix AsyncStructureSpawnEvent crash (#1457) --- .../bukkit/AsyncStructureSpawnEventMixin.java | 16 ++++++++++++++++ .../main/resources/mixins.arclight.bukkit.json | 1 + 2 files changed, 17 insertions(+) create mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/AsyncStructureSpawnEventMixin.java diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/AsyncStructureSpawnEventMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/AsyncStructureSpawnEventMixin.java new file mode 100644 index 000000000..60dfc4061 --- /dev/null +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/AsyncStructureSpawnEventMixin.java @@ -0,0 +1,16 @@ +package io.izzel.arclight.common.mixin.bukkit; + +import org.bukkit.Bukkit; +import org.bukkit.event.world.AsyncStructureSpawnEvent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +@Mixin(value = AsyncStructureSpawnEvent.class, remap = false) +public class AsyncStructureSpawnEventMixin { + + @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lorg/bukkit/event/world/WorldEvent;(Lorg/bukkit/World;Z)V")) + private static boolean arclight$async(boolean async) { + return !Bukkit.isPrimaryThread(); + } +} diff --git a/arclight-common/src/main/resources/mixins.arclight.bukkit.json b/arclight-common/src/main/resources/mixins.arclight.bukkit.json index 74326b422..b976472d2 100644 --- a/arclight-common/src/main/resources/mixins.arclight.bukkit.json +++ b/arclight-common/src/main/resources/mixins.arclight.bukkit.json @@ -10,6 +10,7 @@ }, "compatibilityLevel": "JAVA_17", "mixins": [ + "AsyncStructureSpawnEventMixin", "ColouredConsoleSenderMixin", "CraftAbstractVillagerMixin", "CraftBlockMixin",