Skip to content

Commit

Permalink
Merge pull request #5 from Janoeo/3-wish-list-possibilities
Browse files Browse the repository at this point in the history
Dev Branch for (Wish-list possibilities #3)
  • Loading branch information
AlasDiablo authored May 19, 2022
2 parents de707ba + fb6da1e commit 64eb01e
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 40 deletions.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 2.3.0
+ Add Immersive Engineering
+ Update loading process

### 2.2.0

+ Add create
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/fr/alasdiablo/jerintegration/JERIntegration.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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");
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Block> ore = IEBlocks.Metals.ORES.get(veinType.metal);
IEItems.ItemRegObject<Item> 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
)
);
}

});
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
public class TConstructWorldGen extends WorldGenIntegration {
@Override
public void registerWorldGen(IWorldGenRegistry registry) {
// TODO
}
}
46 changes: 26 additions & 20 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 64eb01e

Please sign in to comment.