Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public final class VanillaBiomes {

public static final int MAX_ID = 255;
public static final int MUTATED_ID_OFFSET = 128;
public static final boolean IDS_ABOVE_255_SUPPORTED = false;

static void init() {
for (Field f : Biome.class.getDeclaredFields()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import net.ornithemc.osl.biomes.api.BiomeRegistry;
import net.ornithemc.osl.biomes.api.biome.BiomeExtension;
import net.ornithemc.osl.biomes.impl.BiomeRegistryImpl;
import net.ornithemc.osl.biomes.impl.BiomesMixinPlugin;
import net.ornithemc.osl.biomes.impl.VanillaBiomes;
import net.ornithemc.osl.registries.api.registry.RegistryKeys;
import net.ornithemc.osl.registries.api.registry.SyncedRegistries;
Expand Down Expand Up @@ -94,12 +93,12 @@ public class BiomeMixin implements BiomeExtension {
id = DynamicArray.length(BY_ID);

// keep 0-255 free for all Vanilla biomes
if (BiomesMixinPlugin.BIOME_IDS_BEYOND_255_SUPPORTED && id <= VanillaBiomes.MAX_ID) {
if (VanillaBiomes.IDS_ABOVE_255_SUPPORTED && id <= VanillaBiomes.MAX_ID) {
id = VanillaBiomes.MAX_ID + 1;
}
}

if (!BiomesMixinPlugin.BIOME_IDS_BEYOND_255_SUPPORTED && id > VanillaBiomes.MAX_ID) {
if (!VanillaBiomes.IDS_ABOVE_255_SUPPORTED && id > VanillaBiomes.MAX_ID) {
throw new IllegalStateException("Biome IDs above 255 are not supported at this time!"
+ " Biome IDs should be limited to the range 0-255"
+ " unless the save format has been modified to support IDs beyond 255.");
Expand Down Expand Up @@ -131,7 +130,7 @@ public class BiomeMixin implements BiomeExtension {
)
)
private static Biome osl$biomes$handleAutoAssignIdForMutatedBiomes(Biome original, int id, Operation<Biome> op) {
if (BiomesMixinPlugin.BIOME_IDS_BEYOND_255_SUPPORTED && original.id > VanillaBiomes.MAX_ID) {
if (VanillaBiomes.IDS_ABOVE_255_SUPPORTED && original.id > VanillaBiomes.MAX_ID) {
// the Biome[] array must contain all biomes so this should
// give us a valid ID for the Biome registry to use.
id = DynamicArray.length(BY_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"minVersion": "0.8",
"package": "net.ornithemc.osl.biomes.impl.mixin",
"compatibilityLevel": "JAVA_8",
"plugin": "net.ornithemc.osl.biomes.impl.BiomesMixinPlugin",
"mixins": [
"common.BiomeMixin"
],
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public final class VanillaBiomes {

public static final int MAX_ID = 255;
public static final int MUTATED_ID_OFFSET = 128;
public static final boolean IDS_ABOVE_255_SUPPORTED = false;

static void init() {
for (Field f : Biome.class.getDeclaredFields()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import net.minecraft.client.gui.screen.world.CustomizeWorldScreen;
import net.minecraft.world.biome.Biome;

import net.ornithemc.conditionalmixin.annotations.Conditional;
import net.ornithemc.conditionalmixin.annotations.Version;

@Conditional(minecraftVersion = @Version(">=14w17a"))
@Mixin(CustomizeWorldScreen.class)
public class CustomizeWorldScreenMixin {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import net.minecraft.client.gui.overlay.DebugOverlay;
import net.minecraft.world.biome.Biome;

import net.ornithemc.conditionalmixin.annotations.Conditional;
import net.ornithemc.conditionalmixin.annotations.Version;

@Conditional(minecraftVersion = @Version(">=14w05a"))
@Mixin(DebugOverlay.class)
public class DebugOverlayMixin {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import net.minecraft.client.gui.GameGui;
import net.minecraft.world.biome.Biome;

import net.ornithemc.conditionalmixin.annotations.Conditional;
import net.ornithemc.conditionalmixin.annotations.Version;

@Conditional(minecraftVersion = @Version("<14w05a"))
@Mixin(GameGui.class)
public class GameGuiMixin {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import net.minecraft.world.biome.Biome;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;

import net.ornithemc.conditionalmixin.annotations.Conditional;
import net.ornithemc.conditionalmixin.annotations.Version;

import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.MutatedBiome;
import net.ornithemc.osl.core.api.util.NamespacedIdentifiers;
import net.ornithemc.osl.core.impl.util.Util;
import net.ornithemc.osl.localization.api.L10n;
import net.ornithemc.osl.biomes.api.BiomeRegistry;
import net.ornithemc.osl.biomes.api.biome.BiomeExtension;
import net.ornithemc.osl.biomes.impl.BiomesMixinPlugin;
import net.ornithemc.osl.biomes.impl.BiomeRegistryImpl;
import net.ornithemc.osl.biomes.impl.VanillaBiomes;
import net.ornithemc.osl.registries.api.registry.RegistryKeys;
import net.ornithemc.osl.registries.api.registry.SyncedRegistries;
Expand All @@ -39,6 +45,30 @@ public class BiomeMixin implements BiomeExtension {
@Unique
private String key;

@Inject(
method = "<clinit>",
at = @At(
value = "HEAD"
)
)
private static void osl$biomes$unlockBiomeRegistry(CallbackInfo ci) {
BiomeRegistryImpl.unlock();
}

@Inject(
method = "<clinit>",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/world/biome/Biome;BY_ID:[Lnet/minecraft/world/biome/Biome;",
opcode = Opcodes.GETSTATIC,
ordinal = 0
)
)
private static void osl$biomes$registerBiomes(CallbackInfo ci) {
BiomeRegistryImpl.registerBiomes();
BiomeRegistryImpl.registerUnknownBiomes();
}

@Inject(
method = "<clinit>",
at = @At(
Expand Down Expand Up @@ -66,12 +96,12 @@ public class BiomeMixin implements BiomeExtension {
id = DynamicArray.length(BY_ID);

// keep 0-255 free for all Vanilla biomes
if (BiomesMixinPlugin.BIOME_IDS_BEYOND_255_SUPPORTED && id <= VanillaBiomes.MAX_ID) {
if (VanillaBiomes.IDS_ABOVE_255_SUPPORTED && id <= VanillaBiomes.MAX_ID) {
id = VanillaBiomes.MAX_ID + 1;
}
}

if (!BiomesMixinPlugin.BIOME_IDS_BEYOND_255_SUPPORTED && id > VanillaBiomes.MAX_ID) {
if (!VanillaBiomes.IDS_ABOVE_255_SUPPORTED && id > VanillaBiomes.MAX_ID) {
throw new IllegalStateException("Biome IDs above 255 are not supported at this time!"
+ " Biome IDs should be limited to the range 0-255"
+ " unless the save format has been modified to support IDs beyond 255.");
Expand All @@ -95,6 +125,42 @@ public class BiomeMixin implements BiomeExtension {
BY_ID = DynamicArray.grow(BY_ID, capacity);
}

@Conditional(minecraftVersion = @Version("<14w05a"))
@WrapOperation(
method = "mutate",
at = @At(
value = "NEW",
target = "net/minecraft/world/biome/MutatedBiome"
)
)
private static MutatedBiome osl$biomes$handleAutoAssignIdForMutatedBiomes(int id, Biome original, Operation<MutatedBiome> op) {
if (VanillaBiomes.IDS_ABOVE_255_SUPPORTED && original.id > VanillaBiomes.MAX_ID) {
// the Biome[] array must contain all biomes so this should
// give us a valid ID for the Biome registry to use.
id = DynamicArray.length(Biome.BY_ID);
}

return op.call(id, original);
}

@Conditional(minecraftVersion = @Version(">=14w05a"))
@WrapOperation(
method = "mutate()Lnet/minecraft/world/biome/Biome;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/biome/Biome;mutate(I)Lnet/minecraft/world/biome/Biome;"
)
)
private static Biome osl$biomes$handleAutoAssignIdForMutatedBiomes(Biome original, int id, Operation<Biome> op) {
if (VanillaBiomes.IDS_ABOVE_255_SUPPORTED && original.id > VanillaBiomes.MAX_ID) {
// the Biome[] array must contain all biomes so this should
// give us a valid ID for the Biome registry to use.
id = DynamicArray.length(Biome.BY_ID);
}

return op.call(original, id);
}

@Override
public String getName() {
if (this.key == null) {
Expand Down

This file was deleted.

Loading
Loading