From 6610499e7c7507e35c2af6b29936740e87cc0f75 Mon Sep 17 00:00:00 2001 From: LuluTheDog Date: Mon, 6 May 2024 18:27:49 +0200 Subject: [PATCH] Added GoG Skybox support for all dimensions (#42) * Added GoG Skybox support for all dimensions - Added a boolean to toggle the feature to the config - Added an int array to contain the dimension you would like to recieve the Skybox -Changed the GoG Skybox render check to include above changes Basically this allows you to display the Garden of Glass in any dimension you wish, instead of just in the overworld. I like to use this to have the skybox in my personal void dimension. * Changed dimension ID to HashSet - Changed the dimension ID handling from int[] to a HashSet of Integers -Added loadPropIntSet() Im sorry if there is better ways to handle the loading of the IDs from the file, this is what i was able to come up with, if theres a way to directly save a set to file please do tell --- .../render/world/SkyblockRenderEvents.java | 10 ++++++- .../common/core/handler/ConfigHandler.java | 30 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java b/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java index 007b637fb..3f4ba4ca2 100644 --- a/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java +++ b/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java @@ -16,13 +16,21 @@ import net.minecraftforge.client.event.RenderWorldLastEvent; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.world.WorldTypeSkyblock; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import java.util.stream.IntStream; public final class SkyblockRenderEvents { @SubscribeEvent public void onRender(RenderWorldLastEvent event) { World world = Minecraft.getMinecraft().theWorld; - if(ConfigHandler.enableFancySkybox && world.provider.dimensionId == 0 && (ConfigHandler.enableFancySkyboxInNormalWorlds || WorldTypeSkyblock.isWorldSkyblock(Minecraft.getMinecraft().theWorld))) { + + boolean renderFancySkybox = ConfigHandler.enableFancySkybox && ( + (ConfigHandler.enableFancySkyboxInNormalWorlds && (world.provider.dimensionId == 0) ) || + (ConfigHandler.enableFancySkyboxInDimension && ConfigHandler.fancySkyboxDimensions.contains(world.provider.dimensionId)) || + (WorldTypeSkyblock.isWorldSkyblock(Minecraft.getMinecraft().theWorld)) + ); + + if(renderFancySkybox) { if(!(world.provider.getSkyRenderer() instanceof SkyblockSkyRenderer)) world.provider.setSkyRenderer(new SkyblockSkyRenderer()); } diff --git a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java index f0c829619..5beb4fd81 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java @@ -11,10 +11,13 @@ package vazkii.botania.common.core.handler; import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.HashMap; import java.util.Map; +import java.util.ArrayList; +import java.util.stream.Collectors; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; @@ -66,6 +69,8 @@ public final class ConfigHandler { public static boolean enableArmorModels = true; public static boolean enableFancySkybox = true; public static boolean enableFancySkyboxInNormalWorlds = false; + public static boolean enableFancySkyboxInDimension = false; + public static HashSet fancySkyboxDimensions = new HashSet() {}; public static int manaBarHeight = 29; public static int flightBarHeight = 49; @@ -197,7 +202,13 @@ public final class ConfigHandler { desc = "Set this to true to enable the fancy skybox in non Garden of Glass worlds. (Does not require Garden of Glass loaded to use, needs 'fancySkybox.enable' to be true as well)"; enableFancySkyboxInNormalWorlds = loadPropBool("fancySkybox.normalWorlds", desc, enableFancySkyboxInNormalWorlds); - + + desc = "Set this to true to enable the fancy skybox in custom dimension. (Does not require Garden of Glass loaded to use, needs 'fancySkybox.enable' to be true as well)"; + enableFancySkyboxInDimension = loadPropBool("fancySkybox.customDim", desc, enableFancySkyboxInDimension); + + desc = "The ID of the dimension to use"; + fancySkyboxDimensions = loadPropIntSet("fancySkybox.customDimID", desc, fancySkyboxDimensions); + desc = "The height of the mana display bar in above the XP bar. You can change this if you have a mod that changes where the XP bar is."; manaBarHeight = loadPropInt("manaBar.height", desc, manaBarHeight); @@ -364,6 +375,19 @@ public final class ConfigHandler { return prop.getIntList(); } + public static HashSet loadPropIntSet(String propName, String desc, HashSet intSet) { + int[] defaultValues = intSet.stream().mapToInt(Number::intValue).toArray(); + Property prop = config.get(Configuration.CATEGORY_GENERAL, propName, defaultValues); + prop.comment = desc; + + if(adaptor != null) + adaptor.adaptPropertyIntArray(prop, prop.getIntList()); + + return Arrays.stream(prop.getIntList()) + .boxed() + .collect(Collectors.toCollection(HashSet::new)); + } + public static int loadPropPotionId(String propName, int default_) { if(!verifiedPotionArray) verifyPotionArray();