From 45b571af427d52e8d232be9204f6986cca2cd61a Mon Sep 17 00:00:00 2001 From: AlasDiablo <25723276+AlasDiablo@users.noreply.github.com> Date: Sat, 9 Apr 2022 11:21:20 +0200 Subject: [PATCH 1/2] feat: back-port Immersive Patch --- build.gradle | 3 +- .../jerintegration/JERIntegration.java | 16 ++++-- .../compat/CompatibilityHandler.java | 13 ++++- .../ImmersiveEngineeringWorldGen.java | 53 +++++++++++++++++++ .../compat/minecraft/MinecraftWorldGen.java | 10 ---- .../compat/tconstruct/TConstructWorldGen.java | 1 + src/main/resources/META-INF/mods.toml | 46 +++++++++------- 7 files changed, 103 insertions(+), 39 deletions(-) create mode 100644 src/main/java/fr/alasdiablo/jerintegration/compat/immersiveengineering/ImmersiveEngineeringWorldGen.java delete mode 100644 src/main/java/fr/alasdiablo/jerintegration/compat/minecraft/MinecraftWorldGen.java diff --git a/build.gradle b/build.gradle index bf0171c..f79790a 100644 --- a/build.gradle +++ b/build.gradle @@ -99,8 +99,7 @@ dependencies { implementation fg.deobf("curse.maven:jei-238222:3670002") // JEI (9.4.1.112) implementation fg.deobf("curse.maven:just-enough-resources-jer-240630:3663200") // JER (0.14.0.155) - implementation fg.deobf("curse.maven:applied-energistics-223794:3615156") - // Applied Energistics 2 (10.0.1 [FORGE]) + implementation fg.deobf("curse.maven:applied-energistics-223794:3615156") // Applied Energistics 2 (10.0.1) implementation fg.deobf("curse.maven:flywheel-486392:3623314") // Flywheel (0.6.0) implementation fg.deobf("curse.maven:create-328085:3623348") // Create (v0.4d) diff --git a/src/main/java/fr/alasdiablo/jerintegration/JERIntegration.java b/src/main/java/fr/alasdiablo/jerintegration/JERIntegration.java index 70d9e3b..04eb6a7 100644 --- a/src/main/java/fr/alasdiablo/jerintegration/JERIntegration.java +++ b/src/main/java/fr/alasdiablo/jerintegration/JERIntegration.java @@ -1,10 +1,10 @@ package fr.alasdiablo.jerintegration; import fr.alasdiablo.jerintegration.compat.CompatibilityHandler; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -14,18 +14,24 @@ public class JERIntegration { public static final Logger LOGGER = LogManager.getLogger(JERIntegration.MOD_ID); private static final ModList MOD_LIST = ModList.get(); public final CompatibilityHandler compatibilityHandler; + public boolean oneTimeLoad = false; public JERIntegration() { this.compatibilityHandler = new CompatibilityHandler(); - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); + MinecraftForge.EVENT_BUS.addListener(this::onPlayerJoinWorld); } - private void setup(final FMLCommonSetupEvent commonSetupEvent) { - this.compatibilityHandler.init(); + private void onPlayerJoinWorld(PlayerEvent.PlayerLoggedInEvent event) { + if (!this.oneTimeLoad) { + this.compatibilityHandler.preInit(); + this.compatibilityHandler.init(); + this.oneTimeLoad = true; + } } public static class Compat { public static boolean AE2 = MOD_LIST.isLoaded("ae2"); public static boolean CREATE = MOD_LIST.isLoaded("create"); + public static boolean IMMERSIVE_ENGINEERING = MOD_LIST.isLoaded("immersiveengineering"); } } diff --git a/src/main/java/fr/alasdiablo/jerintegration/compat/CompatibilityHandler.java b/src/main/java/fr/alasdiablo/jerintegration/compat/CompatibilityHandler.java index d7019e8..b22277c 100644 --- a/src/main/java/fr/alasdiablo/jerintegration/compat/CompatibilityHandler.java +++ b/src/main/java/fr/alasdiablo/jerintegration/compat/CompatibilityHandler.java @@ -4,7 +4,7 @@ import fr.alasdiablo.jerintegration.api.IJERIntegration; import fr.alasdiablo.jerintegration.compat.ae2.AppEngWorldGen; import fr.alasdiablo.jerintegration.compat.create.CreateWorldGen; -import fr.alasdiablo.jerintegration.compat.minecraft.MinecraftWorldGen; +import fr.alasdiablo.jerintegration.compat.immersiveengineering.ImmersiveEngineeringWorldGen; import jeresources.api.IJERAPI; import jeresources.compatibility.JERAPI; @@ -17,9 +17,10 @@ public class CompatibilityHandler { public CompatibilityHandler() { this.compatibilityPatch = new ArrayList<>(); + } + public void preInit() { JERIntegration.LOGGER.info("Applying Minecraft patch"); - this.compatibilityPatch.add(new MinecraftWorldGen()); if (JERIntegration.Compat.AE2) { try { JERIntegration.LOGGER.info("Applying Applied Energistics 2 patch"); @@ -36,6 +37,14 @@ public CompatibilityHandler() { JERIntegration.LOGGER.info("Failing to apply patch for Create"); } } + if (JERIntegration.Compat.IMMERSIVE_ENGINEERING) { + try { + JERIntegration.LOGGER.info("Applying Immersive Engineering patch"); + this.compatibilityPatch.add(new ImmersiveEngineeringWorldGen()); + } catch (Exception e) { + JERIntegration.LOGGER.info("Failing to apply patch for Immersive Engineering"); + } + } } public void init() { diff --git a/src/main/java/fr/alasdiablo/jerintegration/compat/immersiveengineering/ImmersiveEngineeringWorldGen.java b/src/main/java/fr/alasdiablo/jerintegration/compat/immersiveengineering/ImmersiveEngineeringWorldGen.java new file mode 100644 index 0000000..e1d39c4 --- /dev/null +++ b/src/main/java/fr/alasdiablo/jerintegration/compat/immersiveengineering/ImmersiveEngineeringWorldGen.java @@ -0,0 +1,53 @@ +package fr.alasdiablo.jerintegration.compat.immersiveengineering; + +import blusunrize.immersiveengineering.common.config.IEServerConfig; +import blusunrize.immersiveengineering.common.register.IEBlocks; +import blusunrize.immersiveengineering.common.register.IEItems; +import fr.alasdiablo.jerintegration.api.WorldGenIntegration; +import jeresources.api.IWorldGenRegistry; +import jeresources.api.conditionals.Conditional; +import jeresources.api.distributions.DistributionBase; +import jeresources.api.distributions.DistributionSquare; +import jeresources.api.distributions.DistributionTriangular; +import jeresources.api.drop.LootDrop; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; + +public class ImmersiveEngineeringWorldGen extends WorldGenIntegration { + @Override + public void registerWorldGen(IWorldGenRegistry registry) { + IEServerConfig.ORES.ores.forEach((veinType, oreConfig) -> { + IEBlocks.BlockEntry ore = IEBlocks.Metals.ORES.get(veinType.metal); + IEItems.ItemRegObject rawOre = IEItems.Metals.RAW_ORES.get(veinType.metal); + if (ore != null && ore.get() != null) { + DistributionBase distribution; + + try { + if (oreConfig.distribution.get() == IEServerConfig.Ores.OreDistribution.UNIFORM) { + distribution = new DistributionSquare( + oreConfig.veinsPerChunk.get(), oreConfig.veinSize.get(), oreConfig.minY.get(), oreConfig.maxY.get()); + } else { + int range = (oreConfig.maxY.get() - oreConfig.minY.get()) / 2; + int midY = range + oreConfig.minY.get(); + distribution = new DistributionTriangular(oreConfig.veinsPerChunk.get(), oreConfig.veinSize.get(), midY, range); + } + } catch (NullPointerException ignored) { + distribution = new DistributionSquare(oreConfig.veinsPerChunk.get(), oreConfig.veinSize.get(), oreConfig.minY.get(), oreConfig.maxY.get()); + } + + registry.register( + new ItemStack(ore), + distribution, + true, + new LootDrop( + new ItemStack(rawOre.get()), + 1, 1, + Conditional.affectedByFortune + ) + ); + } + + }); + } +} diff --git a/src/main/java/fr/alasdiablo/jerintegration/compat/minecraft/MinecraftWorldGen.java b/src/main/java/fr/alasdiablo/jerintegration/compat/minecraft/MinecraftWorldGen.java deleted file mode 100644 index ce4e329..0000000 --- a/src/main/java/fr/alasdiablo/jerintegration/compat/minecraft/MinecraftWorldGen.java +++ /dev/null @@ -1,10 +0,0 @@ -package fr.alasdiablo.jerintegration.compat.minecraft; - -import fr.alasdiablo.jerintegration.api.WorldGenIntegration; -import jeresources.api.IWorldGenRegistry; - -public class MinecraftWorldGen extends WorldGenIntegration { - @Override - public void registerWorldGen(IWorldGenRegistry registry) { - } -} diff --git a/src/main/java/fr/alasdiablo/jerintegration/compat/tconstruct/TConstructWorldGen.java b/src/main/java/fr/alasdiablo/jerintegration/compat/tconstruct/TConstructWorldGen.java index 829e3cd..90c2cd7 100644 --- a/src/main/java/fr/alasdiablo/jerintegration/compat/tconstruct/TConstructWorldGen.java +++ b/src/main/java/fr/alasdiablo/jerintegration/compat/tconstruct/TConstructWorldGen.java @@ -6,5 +6,6 @@ public class TConstructWorldGen extends WorldGenIntegration { @Override public void registerWorldGen(IWorldGenRegistry registry) { + // TODO } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 8729690..8ad12b0 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -23,27 +23,33 @@ JER Integration for other mod ordering = "NONE" side = "BOTH" [[dependencies.jerintegration]] -modId = "jei" -mandatory = true -versionRange = "[9.4.1.112,)" -ordering = "AFTER" -side = "BOTH" + modId = "jei" + mandatory = true + versionRange = "[9.4.1.112,)" + ordering = "AFTER" + side = "BOTH" +[[dependencies.jerintegration]] + modId = "jeresources" + mandatory = true + versionRange = "[0.14.0.155,)" + ordering = "AFTER" + side = "BOTH" [[dependencies.jerintegration]] -modId = "jeresources" -mandatory = true -versionRange = "[0.14.0.155,)" -ordering = "AFTER" -side = "BOTH" + modId = "ae2" + mandatory = false + versionRange = "[10.0.1,)" + ordering = "AFTER" + side = "BOTH" [[dependencies.jerintegration]] -modId = "ae2" -mandatory = false -versionRange = "[10.0.1,)" -ordering = "AFTER" -side = "BOTH" + modId = "create" + mandatory = false + versionRange = "[0.4d,)" + ordering = "AFTER" + side = "BOTH" [[dependencies.jerintegration]] -modId = "create" -mandatory = false -versionRange = "[0.4d,)" -ordering = "AFTER" -side = "BOTH" + modId = "immersiveengineering" + mandatory = false + versionRange = "[1.18.1-7.1.0-145,)" + ordering = "AFTER" + side = "BOTH" From fb6da1e7603d422d34038d4a64fcc1e45d034bc6 Mon Sep 17 00:00:00 2001 From: AlasDiablo <25723276+AlasDiablo@users.noreply.github.com> Date: Sat, 9 Apr 2022 11:25:21 +0200 Subject: [PATCH 2/2] build: 2.3.0 --- build.gradle | 2 +- changelog.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f79790a..da867f7 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ apply plugin: 'org.spongepowered.mixin' apply plugin: 'maven-publish' def majorVersion = 2 -def minorVersion = 2 +def minorVersion = 3 def buildVersion = 0 def isExperimental = true version = "${majorVersion}.${minorVersion}.${buildVersion}" diff --git a/changelog.md b/changelog.md index 043a865..997f995 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +### 2.3.0 ++ Add Immersive Engineering ++ Update loading process + ### 2.2.0 + Add create