move biome conflict avoidance to config option

This commit is contained in:
FalsePattern committed 2025-06-05 11:47:42 +02:00
1 parent be11ebc4ef
commit a0c174f2e1
5 files changed
+77 -36

No files matched your search

@@ -22,49 +22,20 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.vanilla;
import com.falsepattern.endlessids.PlaceholderBiome;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.world.biome.BiomeGenBase;
@Mixin(BiomeGenBase.class)
public abstract class BiomeGenBaseMixin {
@Shadow
@Final
private static BiomeGenBase[] biomeList;
@Shadow
@Final
public int biomeID;
@ModifyConstant(method = "<clinit>",
constant = @Constant(intValue = VanillaConstants.biomeIDCount),
require = 1)
private static int extendBiomeList(int constant) {
return ExtendedConstants.biomeIDCount;
}
@Inject(method = "<init>(IZ)V",
at = @At(value = "RETURN"),
require = 1)
private void generatePlaceholders(int id, boolean register, CallbackInfo ci) {
if (((Object) this) instanceof PlaceholderBiome || !register) {
return;
}
if (biomeID >= 128 && biomeList[biomeID - 128] == null) {
new PlaceholderBiome(biomeID - 128, (BiomeGenBase) (Object) this);
}
if (biomeID <= ExtendedConstants.biomeIDCount - 129 && biomeList[biomeID + 128] == null) {
new PlaceholderBiome(biomeID + 128, (BiomeGenBase) (Object) this);
}
}
}
@@ -0,0 +1,61 @@
/*
* EndlessIDs
*
* Copyright (C) 2022-2024 FalsePattern
* All Rights Reserved
*
* The above copyright notice, this permission notice and the words "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, either version 3 of the License, or
* (at your option) any later version.
*
* 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 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 <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.endlessids.mixin.mixins.common.biome.vanilla;
import com.falsepattern.endlessids.PlaceholderBiome;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.world.biome.BiomeGenBase;
@Mixin(BiomeGenBase.class)
public abstract class BiomeGenBasePlaceholderMixin {
@Shadow
@Final
private static BiomeGenBase[] biomeList;
@Shadow
@Final
public int biomeID;
@Inject(method = "<init>(IZ)V",
at = @At(value = "RETURN"),
require = 1)
private void generatePlaceholders(int id, boolean register, CallbackInfo ci) {
if (((Object) this) instanceof PlaceholderBiome || !register) {
return;
}
if (biomeID >= 128 && biomeList[biomeID - 128] == null) {
new PlaceholderBiome(biomeID - 128, (BiomeGenBase) (Object) this);
}
if (biomeID <= ExtendedConstants.biomeIDCount - 129 && biomeList[biomeID + 128] == null) {
new PlaceholderBiome(biomeID + 128, (BiomeGenBase) (Object) this);
}
}
}
@@ -52,6 +52,7 @@ public enum Mixin implements IMixin {
//region vanilla
BiomeDictionaryMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.BiomeDictionaryMixin"),
BiomeGenBaseMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.BiomeGenBaseMixin"),
BiomeGenBasePlaceholderMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome && GeneralConfig.biomeConflictAvoidancePlaceholders), "biome.vanilla.BiomeGenBasePlaceholderMixin"),
ChunkMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.ChunkMixin"),
GenLayerRiverMixMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(avoid(TargetedMod.DRAGONAPI)), "biome.vanilla.GenLayerRiverMixMixin"),
GenLayerVoronoiZoomMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.GenLayerVoronoiZoomMixin"),