Ability to swap Overworld and End
This commit is contained in:
parent
02d43cb670
commit
5c4895f757
2 changed files with 28 additions and 0 deletions
|
@ -1,8 +1,10 @@
|
||||||
package ru.betterend.mixin.common;
|
package ru.betterend.mixin.common;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
@ -13,13 +15,21 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.resource.ServerResourceManager;
|
import net.minecraft.resource.ServerResourceManager;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.util.registry.RegistryKey;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import ru.betterend.recipe.EndRecipeManager;
|
import ru.betterend.recipe.EndRecipeManager;
|
||||||
import ru.betterend.registry.EndBiomes;
|
import ru.betterend.registry.EndBiomes;
|
||||||
|
import ru.betterend.world.generator.GeneratorOptions;
|
||||||
|
|
||||||
@Mixin(MinecraftServer.class)
|
@Mixin(MinecraftServer.class)
|
||||||
public class MinecraftServerMixin {
|
public class MinecraftServerMixin {
|
||||||
@Shadow
|
@Shadow
|
||||||
private ServerResourceManager serverResourceManager;
|
private ServerResourceManager serverResourceManager;
|
||||||
|
|
||||||
|
@Final
|
||||||
|
@Shadow
|
||||||
|
private Map<RegistryKey<World>, ServerWorld> worlds;
|
||||||
|
|
||||||
@Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true)
|
@Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true)
|
||||||
private void beOnReload(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> info) {
|
private void beOnReload(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> info) {
|
||||||
|
@ -31,6 +41,18 @@ public class MinecraftServerMixin {
|
||||||
beInjectRecipes();
|
beInjectRecipes();
|
||||||
EndBiomes.initRegistry((MinecraftServer) (Object) this);
|
EndBiomes.initRegistry((MinecraftServer) (Object) this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "getOverworld", at = @At(value = "HEAD"), cancellable = true)
|
||||||
|
private final void beGetOverworld(CallbackInfoReturnable<ServerWorld> info) {
|
||||||
|
if (GeneratorOptions.swapOverworldToEnd()) {
|
||||||
|
ServerWorld world = worlds.get(World.END);
|
||||||
|
if (world == null) {
|
||||||
|
world = worlds.get(World.OVERWORLD);
|
||||||
|
}
|
||||||
|
info.setReturnValue(world);
|
||||||
|
info.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void beInjectRecipes() {
|
private void beInjectRecipes() {
|
||||||
if (FabricLoader.getInstance().isModLoaded("kubejs")) {
|
if (FabricLoader.getInstance().isModLoaded("kubejs")) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ public class GeneratorOptions {
|
||||||
private static boolean hasPortal;
|
private static boolean hasPortal;
|
||||||
private static boolean hasPillars;
|
private static boolean hasPillars;
|
||||||
private static boolean hasDragonFights;
|
private static boolean hasDragonFights;
|
||||||
|
private static boolean swapOverworldToEnd;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
biomeSizeLand = Configs.GENERATOR_CONFIG.getIntRoot("biomeSizeLand", 256);
|
biomeSizeLand = Configs.GENERATOR_CONFIG.getIntRoot("biomeSizeLand", 256);
|
||||||
|
@ -15,6 +16,7 @@ public class GeneratorOptions {
|
||||||
hasPortal = Configs.GENERATOR_CONFIG.getBooleanRoot("hasPortal", true);
|
hasPortal = Configs.GENERATOR_CONFIG.getBooleanRoot("hasPortal", true);
|
||||||
hasPillars = Configs.GENERATOR_CONFIG.getBooleanRoot("hasPillars", true);
|
hasPillars = Configs.GENERATOR_CONFIG.getBooleanRoot("hasPillars", true);
|
||||||
hasDragonFights = Configs.GENERATOR_CONFIG.getBooleanRoot("hasDragonFights", true);
|
hasDragonFights = Configs.GENERATOR_CONFIG.getBooleanRoot("hasDragonFights", true);
|
||||||
|
swapOverworldToEnd = Configs.GENERATOR_CONFIG.getBooleanRoot("swapOverworldToEnd", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getBiomeSizeLand() {
|
public static int getBiomeSizeLand() {
|
||||||
|
@ -36,4 +38,8 @@ public class GeneratorOptions {
|
||||||
public static boolean hasDragonFights() {
|
public static boolean hasDragonFights() {
|
||||||
return hasDragonFights;
|
return hasDragonFights;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean swapOverworldToEnd() {
|
||||||
|
return swapOverworldToEnd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue