From 36cb1b4b320cb79cd48fc9683264358cb9b35f99 Mon Sep 17 00:00:00 2001 From: FalsePattern Date: Wed, 6 Aug 2025 22:10:55 +0200 Subject: [PATCH] fixed crash when trying to set biomes with worldedit --- .../biome/worldedit/ForgeWorldMixin.java | 59 +++++++++++++++++++ .../endlessids/mixin/plugin/Mixin.java | 2 + 2 files changed, 61 insertions(+) create mode 100644 src/main/java/com/falsepattern/endlessids/mixin/mixins/common/biome/worldedit/ForgeWorldMixin.java diff --git a/src/main/java/com/falsepattern/endlessids/mixin/mixins/common/biome/worldedit/ForgeWorldMixin.java b/src/main/java/com/falsepattern/endlessids/mixin/mixins/common/biome/worldedit/ForgeWorldMixin.java new file mode 100644 index 0000000..9e4d931 --- /dev/null +++ b/src/main/java/com/falsepattern/endlessids/mixin/mixins/common/biome/worldedit/ForgeWorldMixin.java @@ -0,0 +1,59 @@ +/* + * EndlessIDs + * + * Copyright (C) 2022-2025 FalsePattern, The MEGA Team + * All Rights Reserved + * + * The above copyright notice, this permission notice and the word "MEGA" + * shall be included in all copies or substantial portions of the Software. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, only version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.falsepattern.endlessids.mixin.mixins.common.biome.worldedit; + +import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook; +import com.sk89q.worldedit.Vector2D; +import com.sk89q.worldedit.forge.ForgeWorld; +import com.sk89q.worldedit.world.biome.BaseBiome; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +import static com.google.common.base.Preconditions.checkNotNull; + +@Mixin(ForgeWorld.class) +public abstract class ForgeWorldMixin { + @Shadow public abstract World getWorld(); + + /** + * @author FalsePattern + * @reason ID Extension + */ + @Overwrite + public boolean setBiome(Vector2D position, BaseBiome biome) { + checkNotNull(position); + checkNotNull(biome); + + Chunk chunk = getWorld().getChunkFromBlockCoords(position.getBlockX(), position.getBlockZ()); + if ((chunk != null) && (chunk.isChunkLoaded)) { + ((ChunkBiomeHook)chunk).getBiomeShortArray()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = (short) biome.getId(); + return true; + } + + return false; + } +} diff --git a/src/main/java/com/falsepattern/endlessids/mixin/plugin/Mixin.java b/src/main/java/com/falsepattern/endlessids/mixin/plugin/Mixin.java index ef36d18..be5e2af 100644 --- a/src/main/java/com/falsepattern/endlessids/mixin/plugin/Mixin.java +++ b/src/main/java/com/falsepattern/endlessids/mixin/plugin/Mixin.java @@ -251,6 +251,8 @@ public class Mixin { biome_witchery_WorldChunkManagerMirrorMixin(EXT_BIOME, require(WITCHERY)), biome_witchery_BrewActionBiomeChangeMixin(EXT_BIOME, require(WITCHERY)), + + biome_worldedit_ForgeWorldMixin(EXT_BIOME, require(WORLDEDIT)), //endregion //region blockitem