From 8fec85d4cb14a414e12c63084f60499189e64dc2 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 30 Oct 2022 18:36:50 +1030 Subject: [PATCH 01/32] Added stuff that people suggested to the update screen --- .../common/wrappers/gui/UpdateModScreen.java | 100 ++++++++++++------ coreSubProjects | 2 +- .../lod/mixins/client/MixinOptionsScreen.java | 2 +- .../lod/mixins/client/MixinOptionsScreen.java | 2 +- 4 files changed, 71 insertions(+), 35 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/gui/UpdateModScreen.java b/common/src/main/java/com/seibel/lod/common/wrappers/gui/UpdateModScreen.java index a382efea3..60e640f59 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/gui/UpdateModScreen.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/gui/UpdateModScreen.java @@ -1,35 +1,31 @@ package com.seibel.lod.common.wrappers.gui; +import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.vertex.PoseStack; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.config.Config; +import com.seibel.lod.core.jar.JarUtils; import com.seibel.lod.core.jar.updater.SelfUpdater; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; -import net.minecraft.client.gui.components.ContainerObjectSelectionList; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.narration.NarratableEntry; +import net.minecraft.client.gui.components.ImageButton; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.Component; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.resources.ResourceLocation; import java.util.*; +/** + * The screen that pops up if the mod has an update. + * + * @author coolGi + */ +// TODO: After finishing the config, rewrite this in openGL as well +// and also maybe add this suggestion https://discord.com/channels/881614130614767666/1035863487110467625/1035949054485594192 public class UpdateModScreen extends Screen { private Screen parent; private String newVersion; - #if PRE_MC_1_19 - public static net.minecraft.network.chat.TranslatableComponent translate (String str, Object... args) { - return new net.minecraft.network.chat.TranslatableComponent(str, args); - } - #else - public static net.minecraft.network.chat.MutableComponent translate (String str, Object... args) { - return net.minecraft.network.chat.Component.translatable(str, args); - } - #endif public UpdateModScreen(Screen parent, String newVersion) { super(translate(ModInfo.ID + ".updater.title")); @@ -42,31 +38,59 @@ public class UpdateModScreen extends Screen { super.init(); + try { + // We cannot get assets from the root of the mod so we use this hack + // TODO: Load the icon.png and logo.png in the mod initialise rather than here + ResourceLocation logoLocation = new ResourceLocation(ModInfo.ID, "logo.png"); + Minecraft.getInstance().getTextureManager().register( + logoLocation, + new DynamicTexture(NativeImage.read(JarUtils.accessFile("logo.png"))) + ); + + + this.addBtn(new ImageButton( + // Where the button is on the screen + this.width / 2 - 100, this.height / 2 - 110, + // Width and height of the button + 200, 100, + // Offset + 0, 0, + // Some textuary stuff + 0, logoLocation, 200, 100, + // Create the button and tell it where to go + // For now it goes to the client option by default + (buttonWidget) -> System.out.println("Nice, you found an easter egg :)"), // TODO: Add a proper easter egg to pressing the logo (maybe with confetti) + // Add a title to the button + translate(ModInfo.ID + ".updater.title") + )); + } catch (Exception e) { e.printStackTrace(); } + + this.addBtn( - new Button(this.width / 2 - 155, this.height / 2, 150, 20, translate(ModInfo.ID + ".updater.update"), (btn) -> { + new Button(this.width / 2 - 155, this.height / 2 + 40, 150, 20, translate(ModInfo.ID + ".updater.update"), (btn) -> { SelfUpdater.deleteOldOnClose = true; SelfUpdater.updateMod(); this.onClose(); }) ); this.addBtn( - new Button(this.width / 2 + 5, this.height / 2, 150, 20, translate(ModInfo.ID + ".updater.later"), (btn) -> { - this.onClose(); - }) - ); - this.addBtn( - new Button(this.width / 2 - 155, this.height / 2 + 25, 150, 20, translate(ModInfo.ID + ".updater.never"), (btn) -> { - Config.Client.AutoUpdater.enableAutoUpdater.set(false); - this.onClose(); - }) - ); - this.addBtn( - new Button(this.width / 2 + 5, this.height / 2 + 25, 150, 20, translate(ModInfo.ID + ".updater.silentUpdate"), (btn) -> { + new Button(this.width / 2 + 5, this.height / 2 + 40, 150, 20, translate(ModInfo.ID + ".updater.silent"), (btn) -> { Config.Client.AutoUpdater.promptForUpdate.set(false); SelfUpdater.updateMod(); this.onClose(); }) ); + this.addBtn( + new Button(this.width / 2 + 5, this.height / 2 + 65, 150, 20, translate(ModInfo.ID + ".updater.later"), (btn) -> { + this.onClose(); + }) + ); + this.addBtn( + new Button(this.width / 2 - 155, this.height / 2 + 65, 150, 20, translate(ModInfo.ID + ".updater.never"), (btn) -> { + Config.Client.AutoUpdater.enableAutoUpdater.set(false); + this.onClose(); + }) + ); } @@ -74,10 +98,12 @@ public class UpdateModScreen extends Screen { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { this.renderBackground(matrices); // Render background - // Render the text's - drawCenteredString(matrices, this.font, translate(ModInfo.ID + ".updater.text1"), this.width / 2, this.height / 2 - 40, 0xFFFFFF); - drawCenteredString(matrices, this.font, translate(ModInfo.ID + ".updater.text2", ModInfo.VERSION, this.newVersion), this.width / 2, this.height / 2 - 25, 0xFFFFFF); + // Render the text's + drawCenteredString(matrices, this.font, translate(ModInfo.ID + ".updater.text1"), this.width / 2, this.height / 2, 0xFFFFFF); + drawCenteredString(matrices, this.font, translate(ModInfo.ID + ".updater.text2", ModInfo.VERSION, this.newVersion), this.width / 2, this.height / 2 + 15, 0x52FD52); + + // TODO: add the tooltips for the buttons super.render(matrices, mouseX, mouseY, delta); // Render the buttons // TODO: Add tooltips @@ -100,4 +126,14 @@ public class UpdateModScreen extends Screen { this.addRenderableWidget(button); #endif } + + #if PRE_MC_1_19 + public static net.minecraft.network.chat.TranslatableComponent translate (String str, Object... args) { + return new net.minecraft.network.chat.TranslatableComponent(str, args); + } + #else + public static net.minecraft.network.chat.MutableComponent translate (String str, Object... args) { + return net.minecraft.network.chat.Component.translatable(str, args); + } + #endif } \ No newline at end of file diff --git a/coreSubProjects b/coreSubProjects index 56f02af57..b9abfaa57 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 56f02af579f9f782f9bceb07f1a87994f6b24173 +Subproject commit b9abfaa5732b4d2277dcef542431bbc43fa302fa diff --git a/fabric/src/main/java/com/seibel/lod/mixins/client/MixinOptionsScreen.java b/fabric/src/main/java/com/seibel/lod/mixins/client/MixinOptionsScreen.java index 5e95a3bc8..2d57ed31f 100644 --- a/fabric/src/main/java/com/seibel/lod/mixins/client/MixinOptionsScreen.java +++ b/fabric/src/main/java/com/seibel/lod/mixins/client/MixinOptionsScreen.java @@ -67,7 +67,7 @@ public class MixinOptionsScreen extends Screen { // Create the button and tell it where to go // For now it goes to the client option by default (buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(GetConfigScreen.getScreen(this)), - // Add a title to the screen + // Add a title to the utton #if PRE_MC_1_19 new TranslatableComponent(ModInfo.ID + ".title"))); #else diff --git a/forge/src/main/java/com/seibel/lod/mixins/client/MixinOptionsScreen.java b/forge/src/main/java/com/seibel/lod/mixins/client/MixinOptionsScreen.java index a284e9215..25a02797c 100644 --- a/forge/src/main/java/com/seibel/lod/mixins/client/MixinOptionsScreen.java +++ b/forge/src/main/java/com/seibel/lod/mixins/client/MixinOptionsScreen.java @@ -67,7 +67,7 @@ public class MixinOptionsScreen extends Screen { // Create the button and tell it where to go // For now it goes to the client option by default (buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(GetConfigScreen.getScreen(this)), - // Add a title to the screen + // Add a title to the button #if PRE_MC_1_19 new TranslatableComponent(ModInfo.ID + ".title"))); #else From 889fc7d7fe91569f27cc3d2c6276b51612523719 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 30 Oct 2022 19:29:25 +1030 Subject: [PATCH 02/32] Fixed mixin plugin and made it be more abstract (sodium class not found bug fixed) --- .../lod/{ => mixins}/FabricMixinPlugin.java | 17 +++++- .../resources/DistantHorizons.mixins.json | 2 +- .../seibel/lod/mixins/ForgeMixinPlugin.java | 61 +++++++++++++++++++ .../resources/DistantHorizons.mixins.json | 3 +- 4 files changed, 78 insertions(+), 5 deletions(-) rename fabric/src/main/java/com/seibel/lod/{ => mixins}/FabricMixinPlugin.java (59%) create mode 100644 forge/src/main/java/com/seibel/lod/mixins/ForgeMixinPlugin.java diff --git a/fabric/src/main/java/com/seibel/lod/FabricMixinPlugin.java b/fabric/src/main/java/com/seibel/lod/mixins/FabricMixinPlugin.java similarity index 59% rename from fabric/src/main/java/com/seibel/lod/FabricMixinPlugin.java rename to fabric/src/main/java/com/seibel/lod/mixins/FabricMixinPlugin.java index 3003b6494..0309130dc 100644 --- a/fabric/src/main/java/com/seibel/lod/FabricMixinPlugin.java +++ b/fabric/src/main/java/com/seibel/lod/mixins/FabricMixinPlugin.java @@ -1,7 +1,8 @@ -package com.seibel.lod; +package com.seibel.lod.mixins; import com.seibel.lod.core.dependencyInjection.ModAccessorInjector; import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor; +import net.fabricmc.loader.api.FabricLoader; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; @@ -9,12 +10,22 @@ import org.spongepowered.asm.mixin.extensibility.IMixinInfo; import java.util.List; import java.util.Set; +/** + * @author coolGi + * @author cortex + */ public class FabricMixinPlugin implements IMixinConfigPlugin { @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - if (mixinClassName.startsWith("mods.sodium")) { - return ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class) != null; + if (mixinClassName.contains(".mods.")) { // If the mixin wants to go into a mod then we check if that mod is loaded or not + return FabricLoader.getInstance().isModLoaded( + mixinClassName + // What these 2 regex's do is get the mod name that we are checking out of the mixinClassName + // Eg. "com.seibel.lod.mixins.mods.sodium.MixinSodiumChunkRenderer" turns into "sodium" + .replaceAll("^.*.mods.", "") // Replaces everything before the mods + .replaceAll("\\..*$", "") // Replaces everything after the mod name + ); } return true; } diff --git a/fabric/src/main/resources/DistantHorizons.mixins.json b/fabric/src/main/resources/DistantHorizons.mixins.json index 7efec5b92..5763e424e 100644 --- a/fabric/src/main/resources/DistantHorizons.mixins.json +++ b/fabric/src/main/resources/DistantHorizons.mixins.json @@ -23,5 +23,5 @@ "injectors": { "defaultRequire": 1 }, - "plugin": "com.seibel.lod.FabricMixinPlugin" + "plugin": "com.seibel.lod.mixins.FabricMixinPlugin" } diff --git a/forge/src/main/java/com/seibel/lod/mixins/ForgeMixinPlugin.java b/forge/src/main/java/com/seibel/lod/mixins/ForgeMixinPlugin.java new file mode 100644 index 000000000..7316789fa --- /dev/null +++ b/forge/src/main/java/com/seibel/lod/mixins/ForgeMixinPlugin.java @@ -0,0 +1,61 @@ +package com.seibel.lod.mixins; + +import net.minecraftforge.fml.ModList; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +/** + * @author coolGi + * @author cortex + */ +public class ForgeMixinPlugin implements IMixinConfigPlugin { + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + if (mixinClassName.contains(".mods.")) { // If the mixin wants to go into a mod then we check if that mod is loaded or not + return ModList.get().isLoaded( + mixinClassName + // What these 2 regex's do is get the mod name that we are checking out of the mixinClassName + // Eg. "com.seibel.lod.mixins.mods.sodium.MixinSodiumChunkRenderer" turns into "sodium" + .replaceAll("^.*.mods.", "") // Replaces everything before the mods + .replaceAll("\\..*$", "") // Replaces everything after the mod name + ); + } + return true; + } + + + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} \ No newline at end of file diff --git a/forge/src/main/resources/DistantHorizons.mixins.json b/forge/src/main/resources/DistantHorizons.mixins.json index 90b22ca44..d7127709d 100644 --- a/forge/src/main/resources/DistantHorizons.mixins.json +++ b/forge/src/main/resources/DistantHorizons.mixins.json @@ -16,5 +16,6 @@ "client.MixinLightmap", "client.MixinOptionsScreen" ], - "server": [] + "server": [], + "plugin": "com.seibel.lod.mixins.ForgeMixinPlugin" } From 43583603622998ecf3d7a7c90681be3faed7b77e Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 30 Oct 2022 19:34:27 +1030 Subject: [PATCH 03/32] Swapped out the bottom 2 buttons on the update screen --- .../com/seibel/lod/common/wrappers/gui/UpdateModScreen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/gui/UpdateModScreen.java b/common/src/main/java/com/seibel/lod/common/wrappers/gui/UpdateModScreen.java index 60e640f59..78b3f7197 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/gui/UpdateModScreen.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/gui/UpdateModScreen.java @@ -81,12 +81,12 @@ public class UpdateModScreen extends Screen { }) ); this.addBtn( - new Button(this.width / 2 + 5, this.height / 2 + 65, 150, 20, translate(ModInfo.ID + ".updater.later"), (btn) -> { + new Button(this.width / 2 - 155, this.height / 2 + 65, 150, 20, translate(ModInfo.ID + ".updater.later"), (btn) -> { this.onClose(); }) ); this.addBtn( - new Button(this.width / 2 - 155, this.height / 2 + 65, 150, 20, translate(ModInfo.ID + ".updater.never"), (btn) -> { + new Button(this.width / 2 + 5, this.height / 2 + 65, 150, 20, translate(ModInfo.ID + ".updater.never"), (btn) -> { Config.Client.AutoUpdater.enableAutoUpdater.set(false); this.onClose(); }) From a5f2ce79e4127b32f945300d116f3a0d8af6e88a Mon Sep 17 00:00:00 2001 From: morippi Date: Tue, 1 Nov 2022 20:29:44 +0100 Subject: [PATCH 04/32] partial fix for ocean holes --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index b9abfaa57..c4957677b 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit b9abfaa5732b4d2277dcef542431bbc43fa302fa +Subproject commit c4957677beef7f7658082e1bc1d66526c8d96e4d From 100401e0ac07b0a3480286340f9401a13bc0f9bd Mon Sep 17 00:00:00 2001 From: morippi Date: Thu, 3 Nov 2022 17:51:39 +0100 Subject: [PATCH 05/32] I made some error with the commits --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index c4957677b..1caf6b03b 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit c4957677beef7f7658082e1bc1d66526c8d96e4d +Subproject commit 1caf6b03b4783db6bbfcada0aed9a40ff04cfca0 From b8ecbdd27dc9e272cee65d484cab2cc6bf6a5edf Mon Sep 17 00:00:00 2001 From: coolGi Date: Fri, 4 Nov 2022 17:35:24 +1030 Subject: [PATCH 06/32] Added a lang auto formatter and a missing lang detector and fixed up the lang formatting and added missing options --- .../com/seibel/lod/common/wrappers/DependencySetup.java | 6 +++--- .../wrappers/gui/{ConfigWrapper.java => LangWrapper.java} | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename common/src/main/java/com/seibel/lod/common/wrappers/gui/{ConfigWrapper.java => LangWrapper.java} (59%) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java b/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java index 3c5a7056f..56a427749 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java @@ -19,9 +19,9 @@ package com.seibel.lod.common.wrappers; -import com.seibel.lod.common.wrappers.gui.ConfigWrapper; +import com.seibel.lod.common.wrappers.gui.LangWrapper; import com.seibel.lod.common.wrappers.minecraft.MinecraftDedicatedServerWrapper; -import com.seibel.lod.core.wrapperInterfaces.config.IConfigWrapper; +import com.seibel.lod.core.wrapperInterfaces.config.ILangWrapper; import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper; import com.seibel.lod.common.wrappers.minecraft.MinecraftRenderWrapper; import com.seibel.lod.core.IReflectionHandler; @@ -49,7 +49,7 @@ public class DependencySetup { public static void createSharedBindings() { SingletonInjector.INSTANCE.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE); // TODO: Remove - SingletonInjector.INSTANCE.bind(IConfigWrapper.class, ConfigWrapper.INSTANCE); + SingletonInjector.INSTANCE.bind(ILangWrapper.class, LangWrapper.INSTANCE); SingletonInjector.INSTANCE.bind(IVersionConstants.class, VersionConstants.INSTANCE); SingletonInjector.INSTANCE.bind(IWrapperFactory.class, WrapperFactory.INSTANCE); DependencySetupDoneCheck.isDone = true; diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/gui/ConfigWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/gui/LangWrapper.java similarity index 59% rename from common/src/main/java/com/seibel/lod/common/wrappers/gui/ConfigWrapper.java rename to common/src/main/java/com/seibel/lod/common/wrappers/gui/LangWrapper.java index b14155ebf..13d799f23 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/gui/ConfigWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/gui/LangWrapper.java @@ -1,10 +1,10 @@ package com.seibel.lod.common.wrappers.gui; -import com.seibel.lod.core.wrapperInterfaces.config.IConfigWrapper; +import com.seibel.lod.core.wrapperInterfaces.config.ILangWrapper; import net.minecraft.client.resources.language.I18n; -public class ConfigWrapper implements IConfigWrapper { - public static final ConfigWrapper INSTANCE = new ConfigWrapper(); +public class LangWrapper implements ILangWrapper { + public static final LangWrapper INSTANCE = new LangWrapper(); @Override public boolean langExists(String str) { return I18n.exists(str); From e174939cf586a6393ec6c3a0731ef64b3e8692eb Mon Sep 17 00:00:00 2001 From: coolGi Date: Fri, 4 Nov 2022 17:37:27 +1030 Subject: [PATCH 07/32] Core doesnt like pushing itself --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 1caf6b03b..4c2a2fffc 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 1caf6b03b4783db6bbfcada0aed9a40ff04cfca0 +Subproject commit 4c2a2fffc1c2d439c99ecd7455f29cead32c0a05 From f75c9ec06a5d0a94224520a12848435a3d1bc426 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 6 Nov 2022 21:41:05 -0600 Subject: [PATCH 08/32] Refactor/comment DhSectionPos, DhLodPos, and DhLodUnit And add BitShiftUtil --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 4c2a2fffc..2429cbbb5 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 4c2a2fffc1c2d439c99ecd7455f29cead32c0a05 +Subproject commit 2429cbbb524f005c9225e4534d10f3eb5f485200 From 4644121fe34be0e810fc63837cafe3064777d65d Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 13 Nov 2022 21:50:10 -0600 Subject: [PATCH 09/32] Add getWrappedMcObject_UNSAFE() to Biome and BlockState Wrappers --- .../common/wrappers/block/BiomeWrapper.java | 7 +++++- .../wrappers/block/BlockStateWrapper.java | 22 +++++++++++-------- coreSubProjects | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/BiomeWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/BiomeWrapper.java index 96c5390f5..3b2daf83d 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/BiomeWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/BiomeWrapper.java @@ -43,7 +43,7 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biomes; -//This class wraps the minecraft BlockPos.Mutable (and BlockPos) class +/** This class wraps the minecraft BlockPos.Mutable (and BlockPos) class */ public class BiomeWrapper implements IBiomeWrapper { #if PRE_MC_1_18_2 @@ -106,4 +106,9 @@ public class BiomeWrapper implements IBiomeWrapper throw new IOException("Failed to deserialize biome wrapper", e); } } + + + @Override + public Object getWrappedMcObject_UNSAFE() { return this.biome; } + } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java index 4f4f6bcbe..ee979d77b 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java @@ -12,7 +12,8 @@ import java.util.HashMap; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -public class BlockStateWrapper implements IBlockStateWrapper { +public class BlockStateWrapper implements IBlockStateWrapper +{ private static final Logger LOGGER = DhLoggerBuilder.getLogger(); public static final BlockStateWrapper AIR = new BlockStateWrapper(null); @@ -65,12 +66,15 @@ public class BlockStateWrapper implements IBlockStateWrapper { public int hashCode() { return Objects.hash(blockState); } - - - - - - - - + + + @Override + public Object getWrappedMcObject_UNSAFE() { return this.blockState; } + + + + + + + } diff --git a/coreSubProjects b/coreSubProjects index 2429cbbb5..cd1c12be1 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 2429cbbb524f005c9225e4534d10f3eb5f485200 +Subproject commit cd1c12be12e86c4bc79674c60864654747933878 From 2daf47f202e31d05b758c5421a74d615816f71a2 Mon Sep 17 00:00:00 2001 From: coolGi Date: Thu, 17 Nov 2022 21:44:43 +1030 Subject: [PATCH 10/32] Updated updater screen (thanks a lot to Pankakes#0686) --- .../wrappers/gui/updater/ChangelogScreen.java | 89 +++++++++++++++++++ .../gui/{ => updater}/UpdateModScreen.java | 47 +++++++--- .../lod/mixins/client/MixinMinecraft.java | 2 +- .../lod/mixins/client/MixinMinecraft.java | 2 +- 4 files changed, 124 insertions(+), 16 deletions(-) create mode 100644 common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/ChangelogScreen.java rename common/src/main/java/com/seibel/lod/common/wrappers/gui/{ => updater}/UpdateModScreen.java (69%) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/ChangelogScreen.java b/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/ChangelogScreen.java new file mode 100644 index 000000000..cfe32d491 --- /dev/null +++ b/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/ChangelogScreen.java @@ -0,0 +1,89 @@ +package com.seibel.lod.common.wrappers.gui.updater; + +import com.mojang.blaze3d.platform.NativeImage; +import com.mojang.blaze3d.vertex.PoseStack; +import com.seibel.lod.common.wrappers.gui.TexturedButtonWidget; +import com.seibel.lod.core.ModInfo; +import com.seibel.lod.core.config.Config; +import com.seibel.lod.core.jar.JarUtils; +import com.seibel.lod.core.jar.updater.SelfUpdater; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.components.ImageButton; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.resources.ResourceLocation; + +import java.util.Objects; + +/** + * The screen that pops up if the mod has an update. + * + * @author coolGi + */ +// TODO: After finishing the config, rewrite this in openGL as well +// TODO: Make this +public class ChangelogScreen extends Screen { + private Screen parent; + private String version; + + + public ChangelogScreen(Screen parent, String version) { + super(translate(ModInfo.ID + ".updater.title")); + this.parent = parent; + this.version = version; + } + + @Override + protected void init() { + super.init(); + + + this.addBtn( // Close + new Button(5, this.height - 25, 100, 20, translate(ModInfo.ID + ".general.back"), (btn) -> { + this.onClose(); + }) + ); + + } + + @Override + public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + this.renderBackground(matrices); // Render background + + + // Render the text + drawCenteredString(matrices, this.font, new TextComponent("Some changelog thing\nIsn't done yet so pls wait"), this.width / 2, this.height / 2 - 35, 0xFFFFFF); + + super.render(matrices, mouseX, mouseY, delta); // Render the buttons + } + + @Override + public void onClose() { + Objects.requireNonNull(minecraft).setScreen(this.parent); // Goto the parent screen + } + + + + + // addRenderableWidget in 1.17 and over + // addButton in 1.16 and below + private void addBtn(Button button) { + #if PRE_MC_1_17_1 + this.addButton(button); + #else + this.addRenderableWidget(button); + #endif + } + + #if PRE_MC_1_19 + public static net.minecraft.network.chat.TranslatableComponent translate (String str, Object... args) { + return new net.minecraft.network.chat.TranslatableComponent(str, args); + } + #else + public static net.minecraft.network.chat.MutableComponent translate (String str, Object... args) { + return net.minecraft.network.chat.Component.translatable(str, args); + } + #endif +} \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/gui/UpdateModScreen.java b/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/UpdateModScreen.java similarity index 69% rename from common/src/main/java/com/seibel/lod/common/wrappers/gui/UpdateModScreen.java rename to common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/UpdateModScreen.java index 78b3f7197..80d34d081 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/gui/UpdateModScreen.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/UpdateModScreen.java @@ -1,7 +1,8 @@ -package com.seibel.lod.common.wrappers.gui; +package com.seibel.lod.common.wrappers.gui.updater; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.vertex.PoseStack; +import com.seibel.lod.common.wrappers.gui.TexturedButtonWidget; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.config.Config; import com.seibel.lod.core.jar.JarUtils; @@ -48,15 +49,16 @@ public class UpdateModScreen extends Screen { ); + // Logo image this.addBtn(new ImageButton( // Where the button is on the screen - this.width / 2 - 100, this.height / 2 - 110, + this.width / 2 - 65, this.height / 2 - 110, // Width and height of the button - 200, 100, + 130, 65, // Offset 0, 0, // Some textuary stuff - 0, logoLocation, 200, 100, + 0, logoLocation, 130, 65, // Create the button and tell it where to go // For now it goes to the client option by default (buttonWidget) -> System.out.println("Nice, you found an easter egg :)"), // TODO: Add a proper easter egg to pressing the logo (maybe with confetti) @@ -66,27 +68,44 @@ public class UpdateModScreen extends Screen { } catch (Exception e) { e.printStackTrace(); } - this.addBtn( - new Button(this.width / 2 - 155, this.height / 2 + 40, 150, 20, translate(ModInfo.ID + ".updater.update"), (btn) -> { + this.addBtn(new TexturedButtonWidget( + // Where the button is on the screen + this.width / 2 - 97, this.height / 2 + 8, + // Width and height of the button + 20, 20, + // Offset + 0, 0, + // Some textuary stuff + 0, new ResourceLocation(ModInfo.ID, "textures/gui/changelog.png"), 20, 20, + // Create the button and tell it where to go + // For now it goes to the client option by default + (buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(new ChangelogScreen(this, this.newVersion)), // TODO: Add a proper easter egg to pressing the logo (maybe with confetti) + // Add a title to the button + translate(ModInfo.ID + ".updater.title") + )); + + + this.addBtn( // Update + new Button(this.width / 2 - 75, this.height / 2 + 8, 150, 20, translate(ModInfo.ID + ".updater.update"), (btn) -> { SelfUpdater.deleteOldOnClose = true; SelfUpdater.updateMod(); this.onClose(); }) ); - this.addBtn( - new Button(this.width / 2 + 5, this.height / 2 + 40, 150, 20, translate(ModInfo.ID + ".updater.silent"), (btn) -> { + this.addBtn( // Silent update + new Button(this.width / 2 - 75, this.height / 2 + 30, 150, 20, translate(ModInfo.ID + ".updater.silent"), (btn) -> { Config.Client.AutoUpdater.promptForUpdate.set(false); SelfUpdater.updateMod(); this.onClose(); }) ); - this.addBtn( - new Button(this.width / 2 - 155, this.height / 2 + 65, 150, 20, translate(ModInfo.ID + ".updater.later"), (btn) -> { + this.addBtn( // Later (not now) + new Button(this.width / 2 + 2, this.height / 2 + 70, 100, 20, translate(ModInfo.ID + ".updater.later"), (btn) -> { this.onClose(); }) ); - this.addBtn( - new Button(this.width / 2 + 5, this.height / 2 + 65, 150, 20, translate(ModInfo.ID + ".updater.never"), (btn) -> { + this.addBtn( // Never + new Button(this.width / 2 - 102, this.height / 2 + 70, 100, 20, translate(ModInfo.ID + ".updater.never"), (btn) -> { Config.Client.AutoUpdater.enableAutoUpdater.set(false); this.onClose(); }) @@ -100,8 +119,8 @@ public class UpdateModScreen extends Screen { // Render the text's - drawCenteredString(matrices, this.font, translate(ModInfo.ID + ".updater.text1"), this.width / 2, this.height / 2, 0xFFFFFF); - drawCenteredString(matrices, this.font, translate(ModInfo.ID + ".updater.text2", ModInfo.VERSION, this.newVersion), this.width / 2, this.height / 2 + 15, 0x52FD52); + drawCenteredString(matrices, this.font, translate(ModInfo.ID + ".updater.text1"), this.width / 2, this.height / 2 - 35, 0xFFFFFF); + drawCenteredString(matrices, this.font, translate(ModInfo.ID + ".updater.text2", ModInfo.VERSION, this.newVersion), this.width / 2, this.height / 2 -20, 0x52FD52); // TODO: add the tooltips for the buttons super.render(matrices, mouseX, mouseY, delta); // Render the buttons diff --git a/fabric/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java b/fabric/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java index 8052c9e4e..db16cdaa7 100644 --- a/fabric/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java +++ b/fabric/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java @@ -1,6 +1,6 @@ package com.seibel.lod.mixins.client; -import com.seibel.lod.common.wrappers.gui.UpdateModScreen; +import com.seibel.lod.common.wrappers.gui.updater.UpdateModScreen; import com.seibel.lod.core.config.Config; import com.seibel.lod.core.dependencyInjection.SingletonInjector; import com.seibel.lod.core.jar.installer.ModrinthGetter; diff --git a/forge/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java b/forge/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java index ab8d7e6e3..4afdd056d 100644 --- a/forge/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java +++ b/forge/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java @@ -1,6 +1,6 @@ package com.seibel.lod.mixins.client; -import com.seibel.lod.common.wrappers.gui.UpdateModScreen; +import com.seibel.lod.common.wrappers.gui.updater.UpdateModScreen; import com.seibel.lod.core.config.Config; import com.seibel.lod.core.dependencyInjection.SingletonInjector; import com.seibel.lod.core.jar.installer.ModrinthGetter; From 7c5ffe3f10c48b3a3bb65d30a47156858ea32943 Mon Sep 17 00:00:00 2001 From: coolGi Date: Thu, 17 Nov 2022 21:46:30 +1030 Subject: [PATCH 11/32] Core doesn't like to push itself --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index cd1c12be1..77519bde9 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit cd1c12be12e86c4bc79674c60864654747933878 +Subproject commit 77519bde9d8a09edc4cd919eb468ed6615b546f5 From de60b15d2b2e36c5a987511343129000ec83f59a Mon Sep 17 00:00:00 2001 From: coolGi Date: Fri, 18 Nov 2022 19:12:25 +1030 Subject: [PATCH 12/32] Added the ChangelogScreen. New changelog screen done --- .../common/wrappers/gui/ClassicConfigGUI.java | 2 +- .../wrappers/gui/updater/ChangelogScreen.java | 117 ++++++++++++++++-- .../wrappers/gui/updater/UpdateModScreen.java | 11 +- .../lod/mixins/client/MixinMinecraft.java | 2 +- .../lod/mixins/client/MixinMinecraft.java | 2 +- 5 files changed, 117 insertions(+), 17 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/lod/common/wrappers/gui/ClassicConfigGUI.java index 272a7d12c..c9f557af6 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/gui/ClassicConfigGUI.java @@ -281,7 +281,7 @@ public abstract class ClassicConfigGUI { drawCenteredString(matrices, font, title, width / 2, 15, 0xFFFFFF); // Render title // Render the tooltip only if it can find a tooltip in the language file - for (AbstractConfigType info : ConfigBase.INSTANCE.entries) { // idk why this is using the normal entries but as long as it works, it works + for (AbstractConfigType info : ConfigBase.INSTANCE.entries) { if (info.getCategory().matches(category) && info.getAppearance().showInGui) { if (list.getHoveredButton(mouseX, mouseY).isPresent()) { AbstractWidget buttonWidget = list.getHoveredButton(mouseX, mouseY).get(); diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/ChangelogScreen.java b/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/ChangelogScreen.java index cfe32d491..31df00cbe 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/ChangelogScreen.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/ChangelogScreen.java @@ -1,21 +1,35 @@ package com.seibel.lod.common.wrappers.gui.updater; +import com.google.common.collect.Lists; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.vertex.PoseStack; -import com.seibel.lod.common.wrappers.gui.TexturedButtonWidget; +import com.seibel.lod.common.wrappers.gui.ClassicConfigGUI; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.config.Config; import com.seibel.lod.core.jar.JarUtils; +import com.seibel.lod.core.jar.installer.MarkdownFormatter; +import com.seibel.lod.core.jar.installer.ModrinthGetter; import com.seibel.lod.core.jar.updater.SelfUpdater; import net.minecraft.client.Minecraft; +import net.minecraft.client.StringSplitter; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.components.ContainerObjectSelectionList; import net.minecraft.client.gui.components.ImageButton; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.network.chat.Style; import net.minecraft.network.chat.TextComponent; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.FormattedCharSequence; -import java.util.Objects; +import java.util.*; /** * The screen that pops up if the mod has an update. @@ -26,13 +40,30 @@ import java.util.Objects; // TODO: Make this public class ChangelogScreen extends Screen { private Screen parent; - private String version; + private String versionID; + private List changelog; + private TextArea changelogArea; - public ChangelogScreen(Screen parent, String version) { + public ChangelogScreen(Screen parent, String versionID) { super(translate(ModInfo.ID + ".updater.title")); this.parent = parent; - this.version = version; + this.versionID = versionID; + + this.changelog = new ArrayList<>(); + // Get the release changelog and split it by the new lines + List unwrappedChangelog = + List.of(new MarkdownFormatter.MinecraftFormat().convertTo( // This formats markdown to minecraft's "§" characters + ModrinthGetter.changeLogs.get(versionID) + ).split("\\n")); + // Makes the words wrap around to not go off the screen + for (String str: unwrappedChangelog) { + this.changelog.addAll( + MarkdownFormatter.splitString(str, 75) + ); + } + // Debugging +// System.out.println(this.changelog); } @Override @@ -46,17 +77,29 @@ public class ChangelogScreen extends Screen { }) ); + + this.changelogArea = new TextArea(this.minecraft, this.width*2, this.height, 32, this.height - 32, 10); + for (int i = 0; i < changelog.size(); i++) { + this.changelogArea.addButton(new TextComponent(changelog.get(i))); +// drawString(matrices, this.font, changelog.get(i), this.width / 2 - 175, this.height / 2 - 100 + i*10, 0xFFFFFF); + } + } @Override public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { this.renderBackground(matrices); // Render background + // Set the scroll position to the mouse height relative to the screen + this.changelogArea.setScrollAmount( + ((double) mouseY)/((double) this.height) * this.changelogArea.getMaxScroll() + ); - // Render the text - drawCenteredString(matrices, this.font, new TextComponent("Some changelog thing\nIsn't done yet so pls wait"), this.width / 2, this.height / 2 - 35, 0xFFFFFF); + this.changelogArea.render(matrices, mouseX, mouseY, delta); // Render the changelog super.render(matrices, mouseX, mouseY, delta); // Render the buttons + + drawCenteredString(matrices, font, title, width / 2, 15, 0xFFFFFF); // Render title } @Override @@ -65,8 +108,6 @@ public class ChangelogScreen extends Screen { } - - // addRenderableWidget in 1.17 and over // addButton in 1.16 and below private void addBtn(Button button) { @@ -86,4 +127,62 @@ public class ChangelogScreen extends Screen { return net.minecraft.network.chat.Component.translatable(str, args); } #endif + + + + + + + + + + + public static class TextArea extends ContainerObjectSelectionList { + Font textRenderer; + + public TextArea(Minecraft minecraftClient, int i, int j, int k, int l, int m) { + super(minecraftClient, i, j, k, l, m); + this.centerListVertically = false; + textRenderer = minecraftClient.font; + } + + public void addButton(Component text) { + this.addEntry(ButtonEntry.create(text)); + } + + @Override + public int getRowWidth() { + return 10000; + } + } + + public static class ButtonEntry extends ContainerObjectSelectionList.Entry { + private static final Font textRenderer = Minecraft.getInstance().font; + private final Component text; + private final List children = new ArrayList<>(); + + private ButtonEntry(Component text) { + this.text = text; + } + + public static ButtonEntry create(Component text) { + return new ButtonEntry(text); + } + + @Override + public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { + GuiComponent.drawString(matrices, textRenderer, text, 12, y + 5, 0xFFFFFF); + } + + @Override + public List children() { + return children; + } + #if POST_MC_1_17_1 + @Override + public List narratables() { + return children; + } + #endif + } } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/UpdateModScreen.java b/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/UpdateModScreen.java index 80d34d081..b91b2ca6d 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/UpdateModScreen.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/gui/updater/UpdateModScreen.java @@ -6,6 +6,7 @@ import com.seibel.lod.common.wrappers.gui.TexturedButtonWidget; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.config.Config; import com.seibel.lod.core.jar.JarUtils; +import com.seibel.lod.core.jar.installer.ModrinthGetter; import com.seibel.lod.core.jar.updater.SelfUpdater; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; @@ -25,13 +26,13 @@ import java.util.*; // and also maybe add this suggestion https://discord.com/channels/881614130614767666/1035863487110467625/1035949054485594192 public class UpdateModScreen extends Screen { private Screen parent; - private String newVersion; + private String newVersionID; - public UpdateModScreen(Screen parent, String newVersion) { + public UpdateModScreen(Screen parent, String newVersionID) { super(translate(ModInfo.ID + ".updater.title")); this.parent = parent; - this.newVersion = newVersion; + this.newVersionID = newVersionID; } @Override @@ -79,7 +80,7 @@ public class UpdateModScreen extends Screen { 0, new ResourceLocation(ModInfo.ID, "textures/gui/changelog.png"), 20, 20, // Create the button and tell it where to go // For now it goes to the client option by default - (buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(new ChangelogScreen(this, this.newVersion)), // TODO: Add a proper easter egg to pressing the logo (maybe with confetti) + (buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(new ChangelogScreen(this, this.newVersionID)), // TODO: Add a proper easter egg to pressing the logo (maybe with confetti) // Add a title to the button translate(ModInfo.ID + ".updater.title") )); @@ -120,7 +121,7 @@ public class UpdateModScreen extends Screen { // Render the text's drawCenteredString(matrices, this.font, translate(ModInfo.ID + ".updater.text1"), this.width / 2, this.height / 2 - 35, 0xFFFFFF); - drawCenteredString(matrices, this.font, translate(ModInfo.ID + ".updater.text2", ModInfo.VERSION, this.newVersion), this.width / 2, this.height / 2 -20, 0x52FD52); + drawCenteredString(matrices, this.font, translate(ModInfo.ID + ".updater.text2", ModInfo.VERSION, ModrinthGetter.releaseNames.get(this.newVersionID)), this.width / 2, this.height / 2 -20, 0x52FD52); // TODO: add the tooltips for the buttons super.render(matrices, mouseX, mouseY, delta); // Render the buttons diff --git a/fabric/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java b/fabric/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java index db16cdaa7..6741eec00 100644 --- a/fabric/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java +++ b/fabric/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java @@ -34,7 +34,7 @@ public class MixinMinecraft if (SelfUpdater.onStart()) { instance.setScreen(new UpdateModScreen( new TitleScreen(false), // We don't want to use the vanilla title screen as it would fade the buttons - ModrinthGetter.getLatestNameForVersion(SingletonInjector.INSTANCE.get(IVersionConstants.class).getMinecraftVersion()) + ModrinthGetter.getLatestIDForVersion(SingletonInjector.INSTANCE.get(IVersionConstants.class).getMinecraftVersion()) )); } else { instance.setScreen(guiScreen); // Sets the screen back to the vanilla screen as if nothing ever happened diff --git a/forge/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java b/forge/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java index 4afdd056d..1cf4923ab 100644 --- a/forge/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java +++ b/forge/src/main/java/com/seibel/lod/mixins/client/MixinMinecraft.java @@ -34,7 +34,7 @@ public class MixinMinecraft if (SelfUpdater.onStart()) { instance.setScreen(new UpdateModScreen( new TitleScreen(false), // We don't want to use the vanilla title screen as it would fade the buttons - ModrinthGetter.getLatestNameForVersion(SingletonInjector.INSTANCE.get(IVersionConstants.class).getMinecraftVersion()) + ModrinthGetter.getLatestIDForVersion(SingletonInjector.INSTANCE.get(IVersionConstants.class).getMinecraftVersion()) )); } else { instance.setScreen(guiScreen); // Sets the screen back to the vanilla screen as if nothing ever happened From 19578f21044e7053cf626d1eda5c610b2e1adef0 Mon Sep 17 00:00:00 2001 From: coolGi Date: Fri, 18 Nov 2022 19:13:00 +1030 Subject: [PATCH 13/32] pushed core --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 77519bde9..b64fdf214 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 77519bde9d8a09edc4cd919eb468ed6615b546f5 +Subproject commit b64fdf214eeeb3aac8f20cd84c4693df67e2bfb0 From 969dfa1dd0c4b4aaf65a707fa5d76ea743deecf1 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 19 Nov 2022 19:06:42 -0600 Subject: [PATCH 14/32] Add isAir() to BlockStateWrapper --- .../lod/common/wrappers/block/BlockStateWrapper.java | 11 +++++++++-- coreSubProjects | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java index ee979d77b..083aac22e 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java @@ -19,8 +19,11 @@ public class BlockStateWrapper implements IBlockStateWrapper public static ConcurrentHashMap cache = new ConcurrentHashMap<>(); - public static BlockStateWrapper fromBlockState(BlockState blockState) { - if (blockState == null || blockState.isAir()) return AIR; + public static BlockStateWrapper fromBlockState(BlockState blockState) + { + if (blockState == null || blockState.isAir()) + return AIR; + if (blockState.getFluidState().isEmpty()) return cache.computeIfAbsent(blockState, BlockStateWrapper::new); else @@ -71,6 +74,10 @@ public class BlockStateWrapper implements IBlockStateWrapper @Override public Object getWrappedMcObject_UNSAFE() { return this.blockState; } + @Override + public boolean isAir() { return this.isAir(this.blockState); } + public boolean isAir(BlockState blockState) { return blockState == null || blockState.isAir(); } + diff --git a/coreSubProjects b/coreSubProjects index cd1c12be1..024989438 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit cd1c12be12e86c4bc79674c60864654747933878 +Subproject commit 02498943866ba91472b65fc9cbef470cfc698c39 From 04d61e81ed64b1eb58a395b91815f2e479e2d107 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 20 Nov 2022 20:39:57 -0600 Subject: [PATCH 15/32] add IDimensionTypeWrapper.equals() --- .../wrappers/world/DimensionTypeWrapper.java | 22 +++++++++++++++++-- coreSubProjects | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/world/DimensionTypeWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/world/DimensionTypeWrapper.java index 825347f99..ad84a9243 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/world/DimensionTypeWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/world/DimensionTypeWrapper.java @@ -22,8 +22,10 @@ package com.seibel.lod.common.wrappers.world; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import com.seibel.lod.api.interfaces.world.IDhApiDimensionTypeWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper; +import net.minecraft.world.level.Level; import net.minecraft.world.level.dimension.DimensionType; /** @@ -84,6 +86,22 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper { return this.dimensionType; } - - + + + + @Override + public boolean equals(Object obj) + { + if (obj.getClass() != DimensionTypeWrapper.class) + { + return false; + } + else + { + DimensionTypeWrapper other = (DimensionTypeWrapper) obj; + return other.getDimensionName().equals(this.getDimensionName()); + } + } + + } diff --git a/coreSubProjects b/coreSubProjects index 2ce8692d8..1b5a10591 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 2ce8692d84dacd513c08914279a14919363d61d1 +Subproject commit 1b5a10591b018febe5a73750d24d549b97fafd99 From af625d912a8a232db1cabd6d92e3d0dd728b2229 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 24 Nov 2022 18:05:15 -0600 Subject: [PATCH 16/32] rename DhApiEventInjector -> ApiEventInjector --- coreSubProjects | 2 +- fabric/src/main/java/com/seibel/lod/FabricMain.java | 6 +++--- forge/src/main/java/com/seibel/lod/ForgeMain.java | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/coreSubProjects b/coreSubProjects index 1b5a10591..0f06fedb9 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 1b5a10591b018febe5a73750d24d549b97fafd99 +Subproject commit 0f06fedb951f98bf2a1278abf95088a5d94de93c diff --git a/fabric/src/main/java/com/seibel/lod/FabricMain.java b/fabric/src/main/java/com/seibel/lod/FabricMain.java index 6a9cd42e8..f7a00ed6d 100644 --- a/fabric/src/main/java/com/seibel/lod/FabricMain.java +++ b/fabric/src/main/java/com/seibel/lod/FabricMain.java @@ -24,7 +24,7 @@ import com.seibel.lod.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent; import com.seibel.lod.common.LodCommonMain; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.config.Config; -import com.seibel.lod.core.DependencyInjection.DhApiEventInjector; +import com.seibel.lod.core.DependencyInjection.ApiEventInjector; import com.seibel.lod.core.dependencyInjection.ModAccessorInjector; import com.seibel.lod.core.dependencyInjection.SingletonInjector; import com.seibel.lod.core.logging.DhLoggerBuilder; @@ -64,7 +64,7 @@ public class FabricMain // This loads the mod after minecraft loads which doesn't causes a lot of issues public static void init() { - DhApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null); + ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null); LOGGER.info("Initializing Mod"); LodCommonMain.startup(null); @@ -85,7 +85,7 @@ public class FabricMain } LOGGER.info(ModInfo.READABLE_NAME + " Initialized"); - DhApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null); + ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null); // Init config // The reason im initialising in this rather than the post init process is cus im using this for the auto updater diff --git a/forge/src/main/java/com/seibel/lod/ForgeMain.java b/forge/src/main/java/com/seibel/lod/ForgeMain.java index ebfb45d34..8fcf20000 100644 --- a/forge/src/main/java/com/seibel/lod/ForgeMain.java +++ b/forge/src/main/java/com/seibel/lod/ForgeMain.java @@ -26,7 +26,7 @@ import com.seibel.lod.common.forge.LodForgeMethodCaller; import com.seibel.lod.common.wrappers.DependencySetup; import com.seibel.lod.common.wrappers.gui.GetConfigScreen; import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper; -import com.seibel.lod.core.DependencyInjection.DhApiEventInjector; +import com.seibel.lod.core.DependencyInjection.ApiEventInjector; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.ReflectionHandler; import com.seibel.lod.core.dependencyInjection.ModAccessorInjector; @@ -115,7 +115,7 @@ public class ForgeMain implements LodForgeMethodCaller private void initCommon() { - DhApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null); + ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null); LodCommonMain.startup(this); ForgeDependencySetup.createInitialBindings(); @@ -140,7 +140,7 @@ public class ForgeMain implements LodForgeMethodCaller LodCommonMain.initConfig(); LOGGER.info("Mod Post-Initialized"); - DhApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null); + ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null); } private final ModelDataMap dataMap = new ModelDataMap.Builder().build(); From a1e8af623d05ebeb6a6ec75d5e7f5967d723b5cc Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 24 Nov 2022 19:10:19 -0600 Subject: [PATCH 17/32] Move Optifine code out of ReflectionHandler and into AbstractOptifineAccessor --- .../java/com/seibel/lod/common/wrappers/DependencySetup.java | 2 +- coreSubProjects | 2 +- .../com/seibel/lod/wrappers/modAccessor/OptifineAccessor.java | 3 ++- forge/src/main/java/com/seibel/lod/ForgeMain.java | 2 +- .../com/seibel/lod/wrappers/modAccessor/OptifineAccessor.java | 3 ++- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java b/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java index 56a427749..ce2355fd3 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java @@ -65,6 +65,6 @@ public class DependencySetup { SingletonInjector.INSTANCE.bind(IMinecraftClientWrapper.class, MinecraftClientWrapper.INSTANCE); SingletonInjector.INSTANCE.bind(IMinecraftSharedWrapper.class, MinecraftClientWrapper.INSTANCE); SingletonInjector.INSTANCE.bind(IMinecraftRenderWrapper.class, MinecraftRenderWrapper.INSTANCE); - SingletonInjector.INSTANCE.bind(IReflectionHandler.class, ReflectionHandler.createSingleton()); + SingletonInjector.INSTANCE.bind(IReflectionHandler.class, ReflectionHandler.INSTANCE); } } diff --git a/coreSubProjects b/coreSubProjects index 0f06fedb9..2b1837e81 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 0f06fedb951f98bf2a1278abf95088a5d94de93c +Subproject commit 2b1837e812821e259f9cf461f48e51840f55bafe diff --git a/fabric/src/main/java/com/seibel/lod/wrappers/modAccessor/OptifineAccessor.java b/fabric/src/main/java/com/seibel/lod/wrappers/modAccessor/OptifineAccessor.java index 0fcd903f2..3d295e77d 100644 --- a/fabric/src/main/java/com/seibel/lod/wrappers/modAccessor/OptifineAccessor.java +++ b/fabric/src/main/java/com/seibel/lod/wrappers/modAccessor/OptifineAccessor.java @@ -22,9 +22,10 @@ package com.seibel.lod.wrappers.modAccessor; import java.util.HashSet; import com.seibel.lod.core.pos.DhChunkPos; +import com.seibel.lod.core.wrapperInterfaces.modAccessor.AbstractOptifineAccessor; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor; -public class OptifineAccessor implements IOptifineAccessor +public class OptifineAccessor extends AbstractOptifineAccessor { @Override diff --git a/forge/src/main/java/com/seibel/lod/ForgeMain.java b/forge/src/main/java/com/seibel/lod/ForgeMain.java index 8fcf20000..983967405 100644 --- a/forge/src/main/java/com/seibel/lod/ForgeMain.java +++ b/forge/src/main/java/com/seibel/lod/ForgeMain.java @@ -121,7 +121,7 @@ public class ForgeMain implements LodForgeMethodCaller ForgeDependencySetup.createInitialBindings(); LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION); - if (ReflectionHandler.instance.optifinePresent()) { + if (ReflectionHandler.INSTANCE.optifinePresent()) { ModAccessorInjector.INSTANCE.bind(IOptifineAccessor.class, new OptifineAccessor()); } #if PRE_MC_1_17_1 diff --git a/forge/src/main/java/com/seibel/lod/wrappers/modAccessor/OptifineAccessor.java b/forge/src/main/java/com/seibel/lod/wrappers/modAccessor/OptifineAccessor.java index 5175f00f1..588d7aecd 100644 --- a/forge/src/main/java/com/seibel/lod/wrappers/modAccessor/OptifineAccessor.java +++ b/forge/src/main/java/com/seibel/lod/wrappers/modAccessor/OptifineAccessor.java @@ -22,9 +22,10 @@ package com.seibel.lod.wrappers.modAccessor; import java.util.HashSet; import com.seibel.lod.core.pos.DhChunkPos; +import com.seibel.lod.core.wrapperInterfaces.modAccessor.AbstractOptifineAccessor; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor; -public class OptifineAccessor implements IOptifineAccessor +public class OptifineAccessor extends AbstractOptifineAccessor { @Override From 954175943d39119423c2f40c4d3acb4995d511b9 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 24 Nov 2022 23:09:06 -0600 Subject: [PATCH 18/32] Fix event related null pointer issues --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 2b1837e81..d6a83c8b6 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 2b1837e812821e259f9cf461f48e51840f55bafe +Subproject commit d6a83c8b61beb7837ea247f80decd3118a491dd0 From 6bd7f54a8edef9097593237c3af4728a78426d09 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 8 Dec 2022 21:36:44 -0600 Subject: [PATCH 19/32] Add WrapperFactory.createChunkWrapper() --- .../lod/common/wrappers/WrapperFactory.java | 106 +++++++++++++++--- .../BatchGenerationEnvironment.java | 3 +- coreSubProjects | 2 +- 3 files changed, 94 insertions(+), 17 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/WrapperFactory.java b/common/src/main/java/com/seibel/lod/common/wrappers/WrapperFactory.java index 9c87bd0c9..d407cd5ba 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/WrapperFactory.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/WrapperFactory.java @@ -19,30 +19,38 @@ package com.seibel.lod.common.wrappers; +import com.seibel.lod.api.interfaces.override.worldGenerator.IDhApiWorldGenerator; import com.seibel.lod.common.wrappers.block.BlockStateWrapper; import com.seibel.lod.common.wrappers.block.BiomeWrapper; +import com.seibel.lod.common.wrappers.chunk.ChunkWrapper; import com.seibel.lod.core.level.IDhLevel; import com.seibel.lod.core.level.IDhServerLevel; import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory; import com.seibel.lod.core.wrapperInterfaces.block.IBlockStateWrapper; +import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper; import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper; import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.chunk.ChunkAccess; import java.io.IOException; /** * This handles creating abstract wrapper objects. - * * @author James Seibel - * @version 11-20-2021 + * @version 2022-12-5 */ public class WrapperFactory implements IWrapperFactory { public static final WrapperFactory INSTANCE = new WrapperFactory(); - + + + + @Override - public AbstractBatchGenerationEnvionmentWrapper createBatchGenerator(IDhLevel targetLevel) { + public AbstractBatchGenerationEnvionmentWrapper createBatchGenerator(IDhLevel targetLevel) + { if (targetLevel instanceof IDhServerLevel) { return new BatchGenerationEnvironment((IDhServerLevel) targetLevel); @@ -52,19 +60,87 @@ public class WrapperFactory implements IWrapperFactory throw new IllegalArgumentException("The target level must be a server-side level."); } } - + @Override - public IBiomeWrapper deserializeBiomeWrapper(String str) throws IOException { - return BiomeWrapper.deserialize(str); - } - + public IBiomeWrapper deserializeBiomeWrapper(String str) throws IOException { return BiomeWrapper.deserialize(str); } + @Override - public IBlockStateWrapper deserializeBlockStateWrapper(String str) throws IOException { - return BlockStateWrapper.deserialize(str); - } - + public IBlockStateWrapper deserializeBlockStateWrapper(String str) throws IOException { return BlockStateWrapper.deserialize(str); } + @Override - public IBlockStateWrapper getAirBlockStateWrapper() { - return BlockStateWrapper.AIR; + public IBlockStateWrapper getAirBlockStateWrapper() { return BlockStateWrapper.AIR; } + + + /** + * Note: when this is updated for different MC versions, make sure you also update the documentation in + * {@link IDhApiWorldGenerator#generateChunks} and the type list in {@link WrapperFactory#createChunkWrapperErrorMessage}.

+ * + * For full method documentation please see: {@link IWrapperFactory#createChunkWrapper} + * @see IWrapperFactory#createChunkWrapper + */ + public IChunkWrapper createChunkWrapper(Object[] objectArray) throws ClassCastException + { + if (objectArray.length == 1 && objectArray[0] instanceof IChunkWrapper) // alternate option if "instanceof" can't be compiled down to older JRE versions "IChunkWrapper.class.isInstance(objectArray[0])" Feel free to delete this comment if we've compiled the mod for 1.16 or earlier - James + { + try + { + // this path should only happen when called by Distant Horizons code + // API implementors should never hit this path + return (IChunkWrapper) objectArray[0]; + } + catch (Exception e) + { + throw new ClassCastException(createChunkWrapperErrorMessage(objectArray)); + } + } + // correct number of parameters from the API + else if (objectArray.length == 2) + { + // chunk + if (!(objectArray[0] instanceof ChunkAccess chunk)) + { + throw new ClassCastException(createChunkWrapperErrorMessage(objectArray)); + } + + // light source + if (!(objectArray[1] instanceof LevelReader lightSource)) + { + throw new ClassCastException(createChunkWrapperErrorMessage(objectArray)); + } + + + return new ChunkWrapper(chunk, lightSource, /*A DH wrapped level isn't necessary*/null); + } + // incorrect number of parameters from the API + else + { + throw new ClassCastException(createChunkWrapperErrorMessage(objectArray)); + } } + /** Note: when this is updated for different MC versions, make sure you also update the documentation in {@link IDhApiWorldGenerator#generateChunks}. */ + private static String createChunkWrapperErrorMessage(Object[] objectArray) + { + StringBuilder message = new StringBuilder( + "Chunk wrapper creation failed. \n" + + "Expected parameters: " + + "[" + ChunkAccess.class.getName() + "], " + + "[" + LevelReader.class.getName() + "]. \n"); + + if (objectArray.length != 0) + { + message.append("Given parameters: "); + for (Object obj : objectArray) + { + message.append("[").append(obj.getClass().getName()).append("], "); + } + } + else + { + message.append(" No parameters given."); + } + + return message.toString(); + } + + } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 7c740b6c7..563878b43 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -527,7 +527,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } @Override - public CompletableFuture generateChunks(int minX, int minZ, int genSize, Steps targetStep, double runTimeRatio, Consumer resultConsumer) { + public CompletableFuture generateChunks(int minX, int minZ, int genSize, Steps targetStep, double runTimeRatio, Consumer resultConsumer) + { // TODO: Check event overlap via e.tooClose() GenerationEvent e = GenerationEvent.startEvent(new DhChunkPos(minX, minZ), genSize, this, targetStep, runTimeRatio, resultConsumer); events.add(e); diff --git a/coreSubProjects b/coreSubProjects index d6a83c8b6..1489cb0bd 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit d6a83c8b61beb7837ea247f80decd3118a491dd0 +Subproject commit 1489cb0bdb1452aa64a9e25882165f7af4ebea59 From df7728707a174230cfdf4019bfe866bc2171dea2 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 10 Dec 2022 21:53:17 -0600 Subject: [PATCH 20/32] Update coreSubProjects --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 1489cb0bd..bf698ad7b 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 1489cb0bdb1452aa64a9e25882165f7af4ebea59 +Subproject commit bf698ad7b9f9d66ae21ce6766c06774733f14763 From 27c3c0c404fe836226e9762c1a6668df3e404fbf Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 10 Dec 2022 22:08:33 -0600 Subject: [PATCH 21/32] rename EDistanceGenerationMode -> EDhApiDistantGeneratorMode --- .../wrappers/worldGeneration/BatchGenerationEnvironment.java | 4 ++-- coreSubProjects | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 563878b43..7e67fd7bb 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -21,13 +21,13 @@ package com.seibel.lod.common.wrappers.worldGeneration; +import com.seibel.lod.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.lod.common.wrappers.world.ServerLevelWrapper; import com.seibel.lod.core.level.IDhServerLevel; import com.seibel.lod.core.config.Config; import com.seibel.lod.api.enums.config.ELightGenerationMode; import com.seibel.lod.core.logging.ConfigBasedLogger; import com.seibel.lod.core.logging.ConfigBasedSpamLogger; -import com.seibel.lod.api.enums.config.EDistanceGenerationMode; import com.seibel.lod.core.pos.DhChunkPos; import com.seibel.lod.core.util.objects.EventTimer; import com.seibel.lod.core.util.LodUtil; @@ -321,7 +321,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv EVENT_LOGGER.debug("Lod Generate Event: " + e.minPos); ArrayGridList referencedChunks; ArrayGridList genChunks; - EDistanceGenerationMode generationMode; + EDhApiDistantGeneratorMode generatorDetail; LightedWorldGenRegion region; WorldGenLevelLightEngine lightEngine; LightGetterAdaptor adaptor; diff --git a/coreSubProjects b/coreSubProjects index bf698ad7b..c3c170d07 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit bf698ad7b9f9d66ae21ce6766c06774733f14763 +Subproject commit c3c170d07a848302b4a2bd621590d0fda107f3ee From 23b35282a911710b10c14b39082b362e8e523889 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 2 Jan 2023 10:32:48 -0600 Subject: [PATCH 22/32] Update Manifold 2022.1.19 -> 2022.1.24 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 52fd61191..dbc5db640 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,7 +20,7 @@ toml_version=3.6.4 nightconfig_version=3.6.6 flatlaf_version=2.3 svgSalamander_version=1.1.3 -manifold_version=2022.1.19 +manifold_version=2022.1.24 mcVersions=1.16.5,1.17.1,1.18.1,1.18.2,1.19,1.19.1,1.19.2 # Internal Properties (These are set at runtime) From 20f8e59f2b65a3c3adbfeb7063cf552fa3bc1e46 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 2 Jan 2023 11:19:50 -0600 Subject: [PATCH 23/32] Remove deprecated ChunkWrapper position getters --- .../common/wrappers/chunk/ChunkWrapper.java | 24 ------------------- coreSubProjects | 2 +- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java index c72ee6b2c..665874da5 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java @@ -20,10 +20,7 @@ package com.seibel.lod.common.wrappers.chunk; import com.seibel.lod.common.wrappers.block.BlockStateWrapper; -import com.seibel.lod.core.pos.DhBlockPos; import com.seibel.lod.core.pos.DhChunkPos; -import com.seibel.lod.core.util.LevelPosUtil; -import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.wrapperInterfaces.block.IBlockStateWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper; @@ -41,7 +38,6 @@ import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkStatus; -import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.levelgen.Heightmap; import javax.annotation.Nullable; @@ -126,26 +122,6 @@ public class ChunkWrapper implements IChunkWrapper return chunk; } - @Override - public int getChunkPosX(){ - return chunk.getPos().x; - } - - @Override - public int getChunkPosZ(){ - return chunk.getPos().z; - } - - @Override - public int getRegionPosX(){ - return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().x, LodUtil.REGION_DETAIL_LEVEL); - } - - @Override - public int getRegionPosZ(){ - return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().z, LodUtil.REGION_DETAIL_LEVEL); - } - @Override public int getMaxY(int x, int z) { return chunk.getHeight(Heightmap.Types.WORLD_SURFACE, Math.floorMod(x, 16), Math.floorMod(z, 16)); diff --git a/coreSubProjects b/coreSubProjects index c3c170d07..1a761aad4 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit c3c170d07a848302b4a2bd621590d0fda107f3ee +Subproject commit 1a761aad4c08601a7fa93623f7bfad5faf70c7b7 From 951ef5ed726b237291cf91ad135103a4f0007a1d Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 8 Jan 2023 20:13:07 -0600 Subject: [PATCH 24/32] Update the ReadMe --- Readme.md | 81 ++++++++++++++++++++++++------------------------- coreSubProjects | 2 +- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/Readme.md b/Readme.md index 0d88b5f80..f4a89ccee 100644 --- a/Readme.md +++ b/Readme.md @@ -5,8 +5,8 @@ # What is Distant Horizons? -This mod adds a Level Of Detail (LOD) system to Minecraft.\ -This implementation renders simplified chunks outside the normal render distance\ +Distant Horizons is a Minecraft mod that adds a Level Of Detail (LOD) system to\ +render simplified chunks outside the normal render distance\ allowing for an increased view distance without harming performance. In other words: this mod lets you see farther without turning your game into a slide show.\ @@ -16,47 +16,42 @@ If you want to see a quick demo, check out a video covering the mod here:
-## Mod and Library Versions +## Minecraft and Library Versions This branch supports the following versions of Minecraft: #### 1.19 (WIP) -Supported MC versions: [1.19]\ -Forge version: 41.0.19\ -Fabric version: 0.14.7\ -Fabric API version: 0.55.3+1.19\ -Modmenu version: 4.0.0 +Forge: 41.0.19\ +Fabric: 0.14.7\ +Fabric API: 0.55.3+1.19\ +Modmenu: 4.0.0 #### 1.18.2 -Supported MC versions: [1.18.2]\ -Forge version: 40.0.18\ -Fabric version: 0.13.3\ -Fabric API version: 0.48.0+1.18.2\ -Modmenu version: 3.1.0 +Forge: 40.0.18\ +Fabric: 0.13.3\ +Fabric API: 0.48.0+1.18.2\ +Modmenu: 3.1.0 -#### 1.18.1 -Supported MC versions: [1.18.1, 1.18]\ -Forge version: 39.1.2\ -Fabric version: 0.13.3\ -Fabric API version: 0.42.6+1.18\ -Modmenu version: 3.0.1 +#### 1.18.1, 1.18 +Forge: 39.1.2\ +Fabric: 0.13.3\ +Fabric API: 0.42.6+1.18\ +Modmenu: 3.0.1 -#### 1.17.1 -Supported MC versions: [1.17.1, 1.17]\ -Forge version: 37.1.1\ -Fabric version: 0.13.2\ -Fabric API version: 0.46.1+1.17\ -Modmenu version: 2.0.14 +#### 1.17.1, 1.17 +Forge: 37.1.1\ +Fabric: 0.13.2\ +Fabric API: 0.46.1+1.17\ +Modmenu: 2.0.14 -#### 1.16.5 -Supported MC versions: [1.16.5, 1.16.4]\ -Forge version: 36.2.28\ -Fabric vetsion: 0.13.2\ -Fabric API version: 0.42.0+1.16\ -Modmenu version: 1.16.22 +#### 1.16.5, 1.16.5 +Forge: 36.2.28\ +Fabric: 0.13.2\ +Fabric API: 0.42.0+1.16\ +Modmenu: 1.16.22

-#### Plugin and Library versions +### Plugin and Library versions Architectury version: 3.4-SNAPSHOT\ Architectury loom version: 0.12.0-SNAPSHOT\ @@ -85,31 +80,35 @@ Java Compiler plugin: Manifold Preprocessor 3. Make sure eclipse has the JDK 17 installed. (This is needed so that eclipse can run minecraft) 4. Import the project into eclipse + + ## Switching Versions -To switch between active versions, change `mcVer=1.?` in `gradle.properties` file. +To switch between different Minecraft versions, change `mcVer=1.?` in the `gradle.properties` file. -If running in an IDE, to ensure the IDE noticed the version change, run a gradle command to prompt gradle into updating the libs. (In IntellJ you will also need to do a gradle sync if it didn't happen automatically.) ->Note: There may be a `java.nio.file.FileSystemException` thrown when running the command after switching versions. To fix it, either restart your IDE (as your IDE is locking up a file) or use a tool like LockHunter to unlock the linked file(s). (Generally it is a lib file under `common\build\lib`, `forge\build\lib`, or `fabric\build\lib`). If anyone knows how to solve this issue please write a comment on this issue: https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/233 +If running in an IDE, to ensure the IDE noticed the version change, run any gradle command to refresh gradle. (In IntellJ you will also need to do a gradle sync if it didn't happen automatically.) +>Note: There may be a `java.nio.file.FileSystemException` thrown when running the command after switching versions. To fix it, either restart your IDE (as your IDE is probably locking a file) or use a tool like LockHunter to unlock the linked file(s). (Generally it is a lib file under `common\build\lib`, `forge\build\lib`, or `fabric\build\lib`). \ +> If anyone knows how to solve this issue please let us know here: \ +> https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/233
## Compiling **From the File Explorer:** -1. Download and extract the zip of the project +1. Download and extract the project zip 2. Download the core from https://gitlab.com/jeseibel/distant-horizons-core and extract into a folder called `core` 3. Open a terminal emulator in the project folder (On Windows you can type `cmd` in the title bar) 4. Run the commands: `./gradlew assemble` 6. The compiled jar file will be in the folder `Merged` -**If in terminal:** +**From the command line:** 1. `git clone --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git` 2. `cd minecraft-lod-mod` 3. `./gradlew assemble` 4. The compiled jar file will be in the folder `Merged` ->Note: You can add the arg: `-PmcVer=1.?` to tell gradle to build a selected MC version instead of having to manually modify the `gradle.properties` file. +>Note: You can add the arg: `-PmcVer=1.?` to tell gradle to build a selected MC version instead of having to modify the `gradle.properties` file.
@@ -117,7 +116,7 @@ If running in an IDE, to ensure the IDE noticed the version change, run a gradle `./gradlew --refresh-dependencies` to refresh local dependencies. -`./gradlew clean` to reset everything (this does not affect your code) and then start the process again. +`./gradlew clean` to delete any compiled code. ## Note to self @@ -132,7 +131,7 @@ If your IDE fails to auto-detect the source jars when browsing Minecraft classes
-## Useful commands +## Other Useful commands Run the standalone jar: `./gradlew run`\ Build the standalone jar: `./gradlew core:build`\ @@ -159,5 +158,5 @@ https://github.com/TheElectronWill/night-config SVG Salamander for SVG's\ https://github.com/blackears/svgSalamander -FlatLaf for theming (Tempory to test stuff)\ +FlatLaf for theming (for development testing)\ https://www.formdev.com/flatlaf/ diff --git a/coreSubProjects b/coreSubProjects index 1a761aad4..98fde3de7 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 1a761aad4c08601a7fa93623f7bfad5faf70c7b7 +Subproject commit 98fde3de74d786311ec947354e85d5de703732aa From c6a7e52a867a8bd1ecb9d42a6063e1f8d4e098ab Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 8 Jan 2023 22:12:58 -0600 Subject: [PATCH 25/32] Improve the compiling instructions in the ReadMe --- Readme.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index f4a89ccee..18085694c 100644 --- a/Readme.md +++ b/Readme.md @@ -95,20 +95,27 @@ If running in an IDE, to ensure the IDE noticed the version change, run any grad ## Compiling -**From the File Explorer:** +Prerequisites: +- JDK 17 or newer + +From the File Explorer: 1. Download and extract the project zip 2. Download the core from https://gitlab.com/jeseibel/distant-horizons-core and extract into a folder called `core` 3. Open a terminal emulator in the project folder (On Windows you can type `cmd` in the title bar) 4. Run the commands: `./gradlew assemble` -6. The compiled jar file will be in the folder `Merged` +5. The compiled jar file will be in the folder `Merged` -**From the command line:** +From the command line: 1. `git clone --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git` 2. `cd minecraft-lod-mod` 3. `./gradlew assemble` 4. The compiled jar file will be in the folder `Merged` ->Note: You can add the arg: `-PmcVer=1.?` to tell gradle to build a selected MC version instead of having to modify the `gradle.properties` file. +Run tests with: `./gradlew test` + +>Note: You can add the arg: `-PmcVer=?` to tell gradle to build a selected MC version instead of having to modify the `gradle.properties` file. \ +> Example: `./gradlew assemble -PmcVer=1.18.2` +
From 6891bdc34e16d17f7325e38a3076f28176d3bb5f Mon Sep 17 00:00:00 2001 From: Jack Works Date: Mon, 9 Jan 2023 04:37:29 +0000 Subject: [PATCH 26/32] Upgrade gradle to support Java 19 --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb8790..070cb702f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 379f8911b5f38b4af277c39ca8615ab9fb552206 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 10 Jan 2023 21:46:48 -0600 Subject: [PATCH 27/32] update manifold 2022.1.24 -> 2022.1.33 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index dbc5db640..091c867e4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,7 +20,7 @@ toml_version=3.6.4 nightconfig_version=3.6.6 flatlaf_version=2.3 svgSalamander_version=1.1.3 -manifold_version=2022.1.24 +manifold_version=2022.1.33 mcVersions=1.16.5,1.17.1,1.18.1,1.18.2,1.19,1.19.1,1.19.2 # Internal Properties (These are set at runtime) From 2f62dd2c4979a71be910755a0426d26feb7b05f3 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 14 Jan 2023 10:56:55 -0600 Subject: [PATCH 28/32] Add Contributing and Code Of Conduct guidelines As requested in merge !24 --- code_of_conduct.md | 78 ++++++++++++++++++++++++++++++++++++++++++++++ contributing.md | 52 +++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 code_of_conduct.md create mode 100644 contributing.md diff --git a/code_of_conduct.md b/code_of_conduct.md new file mode 100644 index 000000000..3a6339e75 --- /dev/null +++ b/code_of_conduct.md @@ -0,0 +1,78 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to make participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies within all project spaces, and it also applies when +an individual is representing the project or its community in public spaces. +Examples of representing a project or community include using an official +project e-mail address, posting via an official social media account, or acting +as an appointed representative at an online or offline event. Representation of +a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the team lead James Seibel through Discord at `@BackSun#4157`. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq + diff --git a/contributing.md b/contributing.md new file mode 100644 index 000000000..13981c4cf --- /dev/null +++ b/contributing.md @@ -0,0 +1,52 @@ +## Contributing + +Thanks for your interest in contributing to Distant Horizons! + +Check out the [Core Wiki](https://gitlab.com/jeseibel/distant-horizons-core/-/wikis/home) for a rough overview of Distant Horizon's project structure. + + + +## Submitting a merge request + +We love merge requests from everyone. + +By sending a merge request, you agree to abide by the Distant Horizons [Contributor Code of Conduct](code_of_conduct.md). \ +Contributions to this project are under the [lesser GPL v3 license](LICENSE.txt) Copyright James Seibel, so please include the [license header](license_header.txt) at the top of any new code files. + +1. Fork, then clone the repo: \ +`git clone --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git` + +2. Set up your dev environment: \ +`./gradlew build` + +3. (Optional) Confirm the tests pass: \ +`./gradlew test` + +4. (Optional) Confirm the game runs with either Forge or Fabric: \ +`./gradlew forge:runClient` \ +`./gradlew fabric:runClient` + +5. Make your change(s). +6. Add tests (if appropriate). + +7. Confirm the tests pass \ +`./gradlew test` + +8. Confirm the game runs with both Forge **and** Fabric: \ +`./gradlew forge:runClient` \ +`./gradlew fabric:runClient` \ +When running the game, load or generate a world to confirm Distant Horizons initializes correctly. + +9. Push to your fork, make sure to include the Core submodule, and submit a [new merge request](https://gitlab.com/jeseibel/minecraft-lod-mod/-/merge_requests/new). + + + +## General Guidelines + +* Check the existing issue list to verify that a given [bug](https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/?sort=created_date&state=opened&label_name%5B%5D=Bug&first_page_size=100), [feature](https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/?sort=created_date&state=opened&label_name%5B%5D=Feature&first_page_size=100), or [improvement](https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/?sort=created_date&state=opened&label_name%5B%5D=Improvement&first_page_size=100) hasn't already been submitted. +* Please open an issue if things aren't working as expected. +* Open a merge request to: fix bugs, fix documentations, improve an existing system, or complete a feature. +* When contributing: + * Put any Minecraft independent code in the [Core](https://gitlab.com/jeseibel/distant-horizons-core) repo when possible. + * Comment and format your code so other people can easily understand it. + From d59fc82cc75ca6be481f0ba00b7f97f0d4f41fd3 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 15 Jan 2023 20:03:12 -0600 Subject: [PATCH 29/32] refactor Generation Event and Environment --- .../BatchGenerationEnvironment.java | 18 +-- .../worldGeneration/GenerationEvent.java | 112 +++++++++++------- coreSubProjects | 2 +- 3 files changed, 76 insertions(+), 56 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 7e67fd7bb..eb81b2d72 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -362,7 +362,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv region = new LightedWorldGenRegion(params.level, lightEngine, referencedChunks, ChunkStatus.STRUCTURE_STARTS, refSize/2, e.lightMode, generator); adaptor.setRegion(region); - e.tParam.makeStructFeat(region, params); + e.threadedParam.makeStructFeat(region, params); genChunks = new ArrayGridList<>(referencedChunks, RANGE_TO_RANGE_EMPTY_EXTENSION, referencedChunks.gridSize - RANGE_TO_RANGE_EMPTY_EXTENSION); generateDirect(e, genChunks, e.target, region); @@ -370,7 +370,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } catch (StepStructureStart.StructStartCorruptedException f) { - e.tParam.markAsInvalid(); + e.threadedParam.markAsInvalid(); throw (RuntimeException)f.getCause(); } @@ -418,7 +418,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv e.refreshTimeout(); if (PREF_LOGGER.canMaybeLog()) { - e.tParam.perf.recordEvent(e.timer); + e.threadedParam.perf.recordEvent(e.timer); PREF_LOGGER.infoInc("{}", e.timer); } } @@ -439,27 +439,27 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv if (step == Steps.Empty) return; e.timer.nextEvent("structStart"); - stepStructureStart.generateGroup(e.tParam, region, subRange); + stepStructureStart.generateGroup(e.threadedParam, region, subRange); e.refreshTimeout(); if (step == Steps.StructureStart) return; e.timer.nextEvent("structRef"); - stepStructureReference.generateGroup(e.tParam, region, subRange); + stepStructureReference.generateGroup(e.threadedParam, region, subRange); e.refreshTimeout(); if (step == Steps.StructureReference) return; e.timer.nextEvent("biome"); - stepBiomes.generateGroup(e.tParam, region, subRange); + stepBiomes.generateGroup(e.threadedParam, region, subRange); e.refreshTimeout(); if (step == Steps.Biomes) return; e.timer.nextEvent("noise"); - stepNoise.generateGroup(e.tParam, region, subRange); + stepNoise.generateGroup(e.threadedParam, region, subRange); e.refreshTimeout(); if (step == Steps.Noise) return; e.timer.nextEvent("surface"); - stepSurface.generateGroup(e.tParam, region, subRange); + stepSurface.generateGroup(e.threadedParam, region, subRange); e.refreshTimeout(); if (step == Steps.Surface) return; @@ -467,7 +467,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv if (step == Steps.Carvers) return; e.timer.nextEvent("feature"); - stepFeatures.generateGroup(e.tParam, region, subRange); + stepFeatures.generateGroup(e.threadedParam, region, subRange); e.refreshTimeout(); } finally diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java index abed31898..fe9bc56cd 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ - + package com.seibel.lod.common.wrappers.worldGeneration; import java.lang.invoke.MethodHandles; @@ -41,7 +41,7 @@ public final class GenerationEvent private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName()); private static int generationFutureDebugIDs = 0; final int id; - final ThreadedParameters tParam; + final ThreadedParameters threadedParam; final DhChunkPos minPos; final int size; final Steps target; @@ -52,93 +52,113 @@ public final class GenerationEvent long timeoutTime = -1; public CompletableFuture future = null; final Consumer resultConsumer; - + + + public GenerationEvent(DhChunkPos minPos, int size, BatchGenerationEnvironment generationGroup, - Steps target, double runTimeRatio, Consumer resultConsumer) { - inQueueTime = System.nanoTime(); + Steps target, double runTimeRatio, Consumer resultConsumer) + { + this.inQueueTime = System.nanoTime(); this.id = generationFutureDebugIDs++; this.minPos = minPos; this.size = size; this.target = target; - this.tParam = ThreadedParameters.getOrMake(generationGroup.params); + this.threadedParam = ThreadedParameters.getOrMake(generationGroup.params); this.lightMode = Config.Client.WorldGenerator.lightGenerationMode.get(); this.runTimeRatio = runTimeRatio; this.resultConsumer = resultConsumer; } - + + + public static GenerationEvent startEvent(DhChunkPos minPos, int size, BatchGenerationEnvironment generationGroup, - Steps target, double runTimeRatio, Consumer resultConsumer) + Steps target, double runTimeRatio, Consumer resultConsumer) { - if (size % 2 == 0) size += 1; // size must be odd for vanilla world gen region to work + if (size % 2 == 0) + { + size += 1; // size must be odd for vanilla world gen regions to work + } + GenerationEvent event = new GenerationEvent(minPos, size, generationGroup, target, runTimeRatio, resultConsumer); event.future = CompletableFuture.runAsync(() -> + { + long runStartTime = System.nanoTime(); + event.timeoutTime = runStartTime; + event.inQueueTime = runStartTime - event.inQueueTime; + event.timer = new EventTimer("setup"); + BatchGenerationEnvironment.isDistantGeneratorThread.set(true); + try + { + LOGGER.info("generating [{}]", event.minPos); + generationGroup.generateLodFromList(event); + } + finally + { + BatchGenerationEnvironment.isDistantGeneratorThread.remove(); + if (!Thread.interrupted() && runTimeRatio < 1.0) { - long runStartTime = System.nanoTime(); - event.timeoutTime = runStartTime; - event.inQueueTime = runStartTime - event.inQueueTime; - event.timer = new EventTimer("setup"); - BatchGenerationEnvironment.isDistantGeneratorThread.set(true); - try { - generationGroup.generateLodFromList(event); - } finally { - BatchGenerationEnvironment.isDistantGeneratorThread.remove(); - if (!Thread.interrupted() && runTimeRatio < 1.0) { - long endTime = System.nanoTime(); - try { - long deltaMs = TimeUnit.NANOSECONDS.toMillis(endTime - runStartTime); - Thread.sleep((long) (deltaMs/runTimeRatio - deltaMs)); - } catch (InterruptedException ignored) {} - } + long endTime = System.nanoTime(); + try + { + long deltaMs = TimeUnit.NANOSECONDS.toMillis(endTime - runStartTime); + Thread.sleep((long) (deltaMs / runTimeRatio - deltaMs)); } - }, generationGroup.executors); + catch (InterruptedException ignored) + { + } + } + } + }, generationGroup.executors); return event; } - - public boolean isComplete() - { - return future.isDone(); - } - + + public boolean isComplete() { return this.future.isDone(); } + public boolean hasTimeout(int duration, TimeUnit unit) { - if (timeoutTime == -1) return false; + if (this.timeoutTime == -1) + { + return false; + } + long currentTime = System.nanoTime(); - long delta = currentTime - timeoutTime; + long delta = currentTime - this.timeoutTime; return (delta > TimeUnit.NANOSECONDS.convert(duration, unit)); } - + public boolean terminate() { LOGGER.info("======================DUMPING ALL THREADS FOR WORLD GEN======================="); BatchGenerationEnvironment.threadFactory.dumpAllThreadStacks(); - future.cancel(true); - return future.isCancelled(); + this.future.cancel(true); + return this.future.isCancelled(); } - public boolean tooClose(int minX, int minZ, int w) + public boolean tooClose(int minX, int minZ, int width) { - int aMinX = minPos.x; - int aMinZ = minPos.z; - int aSize = size; + int aMinX = this.minPos.x; + int aMinZ = this.minPos.z; + int aSize = this.size; // Account for required empty chunks in the border aSize += 1; - w+= 1; + width += 1; // Do a AABB to AABB intersection test return (aMinX + aSize >= minX && - aMinX <= minX + w && + aMinX <= minX + width && aMinZ + aSize >= minZ && - aMinZ <= minZ + w); + aMinZ <= minZ + width); } public void refreshTimeout() { - timeoutTime = System.nanoTime(); + this.timeoutTime = System.nanoTime(); UncheckedInterruptedException.throwIfInterrupted(); } @Override public String toString() { - return id + ":" + size + "@" + minPos + "(" + target + ")"; + return this.id + ":" + this.size + "@" + this.minPos + "(" + this.target + ")"; } + } \ No newline at end of file diff --git a/coreSubProjects b/coreSubProjects index 98fde3de7..59d5b475c 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 98fde3de74d786311ec947354e85d5de703732aa +Subproject commit 59d5b475c5ec9208122aa7b3b6ccc03d88115b49 From dd6380d49dbeeb654466e6ce41553a6cc9724cb3 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 22 Jan 2023 17:12:49 -0600 Subject: [PATCH 30/32] rename AbstractWorldGenTaskTracker.isValid -> isMemoryAddressValid --- .../com/seibel/lod/common/wrappers/gui/ClassicConfigGUI.java | 4 ++-- coreSubProjects | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/lod/common/wrappers/gui/ClassicConfigGUI.java index c9f557af6..3966b7574 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/gui/ClassicConfigGUI.java @@ -113,7 +113,7 @@ public abstract class ClassicConfigGUI { #if PRE_MC_1_19 ((EntryInfo) info.guiValue).error = ((ConfigEntry) info).isValid(value) == 0 ? null : new AbstractMap.SimpleEntry<>(editBox, new TextComponent(((ConfigEntry) info).isValid(value) == -1 ? #else - ((EntryInfo) info.guiValue).error = ((ConfigEntry) info).isValid(value) == 0 ? null : new AbstractMap.SimpleEntry<>(editBox, Component.translatable(((ConfigEntry) info).isValid(value) == -1 ? + ((EntryInfo) info.guiValue).error = ((ConfigEntry) info).isValidMemoryAddress(value) == 0 ? null : new AbstractMap.SimpleEntry<>(editBox, Component.translatable(((ConfigEntry) info).isValidMemoryAddress(value) == -1 ? #endif "§cMinimum " + "length" + (cast ? " is " + (int) ((ConfigEntry) info).getMin() : " is " + ((ConfigEntry) info).getMin()) : "§cMaximum " + "length" + (cast ? " is " + (int) ((ConfigEntry) info).getMax() : " is " + ((ConfigEntry) info).getMax()))); @@ -130,7 +130,7 @@ public abstract class ClassicConfigGUI { else ((ConfigEntry) info).setWithoutSaving(value.intValue()); } -// else if (((ConfigEntry) info).isValid() == 0) +// else if (((ConfigEntry) info).isValidMemoryAddress() == 0) // { // if (((List) info.get()).size() == ((EntryInfo) info.guiValue).index) // info.set(((List) info.get()).add("")); diff --git a/coreSubProjects b/coreSubProjects index 59d5b475c..fde9f6f12 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 59d5b475c5ec9208122aa7b3b6ccc03d88115b49 +Subproject commit fde9f6f129b5082e1d22688f94bda96ebea73294 From bf2ffd6dfbf39353f6ba7f6a5b7bef9b408ebf8d Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 22 Jan 2023 19:56:44 -0600 Subject: [PATCH 31/32] Update coreSubProjects --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index fde9f6f12..8b9a2f80b 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit fde9f6f129b5082e1d22688f94bda96ebea73294 +Subproject commit 8b9a2f80b708e47195dd1711a68010b358638882 From af6f477f15a70f69829701804e993ace30c6bdd0 Mon Sep 17 00:00:00 2001 From: coolGi Date: Tue, 24 Jan 2023 18:14:08 +1030 Subject: [PATCH 32/32] Updated core submodule --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 8b9a2f80b..226fa9056 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 8b9a2f80b708e47195dd1711a68010b358638882 +Subproject commit 226fa90561e432da193445b1f35849cce5f7e27f