Skip to content

Commit

Permalink
Allow Setting Default Fluids + AR Integration
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Jan 24, 2024
1 parent 3d472c3 commit 6b1c70a
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 17 deletions.
12 changes: 7 additions & 5 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,14 @@ dependencies {
compileOnly rfg.deobf("curse.maven:nuclearcraft-mod-226254:3074246") // Version 2.18y (Newer versions have unneeded balancing changes and break stuff)
compileOnly rfg.deobf("curse.maven:extra-utilities-225561:2678374") // Version 1.9.9, also has remapping to remove frequency

// Solar Flux Reborn, need to be patched for Cleanroom compatibility (from CurseForge)
compileOnly rfg.deobf("curse.maven:solar-flux-reborn-246974:3050838") // Version 12.4.11

// Brandon Core & Redstone Flux, Runtime and Compile Dep of Draconic Evolution (from CurseForge)
compileOnly rfg.deobf("curse.maven:brandons-core-231382:3408276") // Version 2.4.20
compileOnly rfg.deobf("curse.maven:redstone-flux-270789:2920436") // Version 2.1.1.1

// Lib Vulpes and Advanced Rocketry (from CurseForge)
compileOnly rfg.deobf("curse.maven:libvulpes-236541:2949886") // Version 0.4.2-75 (Newer Versions Crash with Gas Charge Pad)
compileOnly rfg.deobf("curse.maven:advanced-rocketry-236542:3015079") // Version 1.7.0-232 (Newer Versions need Newer Lib Vulpes)

/* -------------------------------- Soft Deps, Multiple Runtime Declaration -------------------------------- */
if (project.enable_draconic.toBoolean() || project.enable_thermal.toBoolean()) {
runtimeOnly "curse.maven:redstone-flux-270789:2920436" // Version 2.1.1.1
Expand Down Expand Up @@ -148,8 +149,9 @@ dependencies {
runtimeOnly "curse.maven:extra-utilities-225561:2678374" // Version 1.9.9
}

if (project.enable_solar.toBoolean()) {
runtimeOnly "curse.maven:solar-flux-reborn-246974:3050838" // Version 12.4.11
if (project.enable_rocketry.toBoolean()) {
runtimeOnly "curse.maven:libvulpes-236541:2949886" // Version 0.4.2-75 (Newer Versions Crash with Gas Charge Pad)
runtimeOnly "curse.maven:advanced-rocketry-236542:3015079" // Version 1.7.0-232 (Newer Versions need Newer Lib Vulpes)
}

if (project.enable_ender_storage.toBoolean()) {
Expand Down
9 changes: 6 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ curseForgeRelations = requiredDependency:codechicken-lib-1-8;\
optionalDependency:thermal-foundation;\
optionalDependency:redstone-arsenal;\
optionalDependency:cofh-world;\
optionalDependency:cofh-core;
optionalDependency:cofh-core;\
optionalDependency:libvulpes;\
optionalDependency:advanced-rocketry;

# This project's release type on CurseForge and/or Modrinth
# Alternatively this can be set with the 'RELEASE_TYPE' environment variable.
Expand Down Expand Up @@ -233,9 +235,10 @@ enable_nuclear = false
# If this is set to false, the mixin and remappers will not apply.
enable_xu2 = false

# Whether to enable Solar Flux Reborn in runtime. Enables the mixin, which allows its compatability with Cleanroom Loader.
# Whether to enable Advanced Rocketry in runtime. Enables the mixin which fixes Advanced Rocketry adding items for fluid blocks.
# This was fixed in later versions, but we cannot update due to another crash.
# If this is set to false, the mixin will not apply.
enable_solar = false
enable_rocketry = false

# Whether to enable Ender Storage in runtime. Enables remappers to remap items in ender storage.
# If this is set to false, the remappers will not apply there.
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/nomiceu/nomilabs/LabsValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ public class LabsValues {
public static final String FRAMED_COMPACT_MODID = "framedcompactdrawers";
public static final String ENDER_IO_MODID = "enderio";
public static final String JEI_MODID = "jei";
public static final String ROCKETRY_MODID = "advancedrocketry";
}
2 changes: 2 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/NomiLabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
+ "required-after:packmode;"
+ "required-after:jei@[4.15.0,);"
+ "required-after:theoneprobe;"
+ "after:advancedrocketry;"
+ "after:libvulpes;"
+ "after:crafttweaker@[4.1.20,);"
+ "after:appliedenergistics2;")
@SuppressWarnings("unused")
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ public static class ModIntegration {
@Config.Name("draconic evolution integration")
public final DraconicEvolutionIntegration draconicEvolutionIntegration = new DraconicEvolutionIntegration();

@Config.Comment({"Whether to enable Advanced Rocketry Integration, which fixes Advanced Rocketry registering items for Fluid Blocks.",
"[default: true]"})
@Config.LangKey("config.nomilabs.mod_integration.advanced_rocketry")
@Config.RequiresMcRestart
public boolean enableAdvancedRocketryIntegration = true;

public static class DraconicEvolutionIntegration {
@Config.Comment({"Whether to enable Draconic Evolution Integration, which adds many features, such as:",
"Allowing GregTech Draconium and Awakened Draconium in the reactor and energy core.",
Expand Down Expand Up @@ -224,6 +230,12 @@ public static class Advanced {
@Config.RequiresWorldRestart
public boolean enableNomiCEuDataFixes = false;

@Config.Comment({"List of Resource Locations to be Default Fluids.",
"If multiple fluids with the same name match a resource location, the last one will be picked.",
"[default: ]"})
@Config.LangKey("config.nomilabs.advanced.default_fluids")
public String[] defaultFluids = new String[0];

@Config.Comment({"List of Regex Patterns to ignore if they are included in the ITEM missing registry list.",
"Do not change unless you know what you are doing!",
"This can be very inefficient with lots of patterns and lots of missing registries. Try to condense it into one pattern!",
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/com/nomiceu/nomilabs/core/LabsLateMixin.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
package com.nomiceu.nomilabs.core;

import com.google.common.collect.ImmutableMap;
import com.nomiceu.nomilabs.LabsValues;
import com.nomiceu.nomilabs.config.LabsConfig;
import net.minecraftforge.fml.common.Loader;
import zone.rong.mixinbooter.ILateMixinLoader;

import java.util.AbstractMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static com.nomiceu.nomilabs.NomiLabs.LOGGER;

@SuppressWarnings("unused")
public class LabsLateMixin implements ILateMixinLoader {
public static final Map<String, Boolean> modMixinsConfig = ImmutableMap.of(
LabsValues.DRACONIC_MODID, LabsConfig.modIntegration.draconicEvolutionIntegration.enableDraconicEvolutionIntegration,
LabsValues.NUCLEARCRAFT_MODID, LabsConfig.modIntegration.enableNuclearCraftIntegration,
LabsValues.XU2_MODID, LabsConfig.modIntegration.enableExtraUtils2Integration,
LabsValues.GREGTECH_MODID, true,
LabsValues.JEI_MODID, true
);
public static final Map<String, Boolean> modMixinsConfig = Stream.of(
new AbstractMap.SimpleImmutableEntry<>(LabsValues.DRACONIC_MODID,
LabsConfig.modIntegration.draconicEvolutionIntegration.enableDraconicEvolutionIntegration),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.NUCLEARCRAFT_MODID,
LabsConfig.modIntegration.enableNuclearCraftIntegration),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.XU2_MODID,
LabsConfig.modIntegration.enableExtraUtils2Integration),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.GREGTECH_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.JEI_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.ROCKETRY_MODID,
LabsConfig.modIntegration.enableAdvancedRocketryIntegration))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

@Override
public List<String> getMixinConfigs() {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/fluid/FluidBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class FluidBase extends Fluid {
public FluidBase(String name, int color, int viscosity, int luminosity) {
super(name, stillLocation, flowingLocation, color);



this.viscosity = viscosity;
this.luminosity = luminosity;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/nomiceu/nomilabs/groovy/ReplaceRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -82,7 +83,7 @@ public static void replaceRecipeInput(ResourceLocation name, List<List<IIngredie
}

public static void changeStackRecycling(ItemStack output, List<IIngredient> ingredients) {
registerRecycling(output, ImmutableList.of(ingredients));
registerRecycling(output, Collections.singletonList(ingredients));
}

private static IShapedRecipe validate(ResourceLocation name, ItemStack output, boolean validateOutput) {
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/mixin/FluidRegistryMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.nomiceu.nomilabs.mixin;

import com.google.common.collect.BiMap;
import com.nomiceu.nomilabs.NomiLabs;
import com.nomiceu.nomilabs.config.LabsConfig;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Set;

@Mixin(value = FluidRegistry.class, remap = false)
public class FluidRegistryMixin {
@Shadow
static BiMap<String, Fluid> fluids;

@Shadow
static BiMap<Fluid, Integer> fluidIDs;

@Shadow
static BiMap<Integer, String> fluidNames;

@Shadow
static BiMap<String, String> defaultFluidName;

@Shadow
static BiMap<String, Fluid> masterFluidReference;

@Inject(method = "loadFluidDefaults(Lcom/google/common/collect/BiMap;Ljava/util/Set;)V", at = @At(
value = "FIELD",
target = "Lnet/minecraftforge/fluids/FluidRegistry;currentBucketFluids:Ljava/util/Set;",
shift = At.Shift.AFTER),
require = 1)
private static void loadSpecifiedFluidDefaults(BiMap<Fluid, Integer> localFluidIDs, Set<String> defaultNames, CallbackInfo ci) {
if (LabsConfig.advanced.defaultFluids.length == 0) return;
int changed = 0;
for (var fluidName : LabsConfig.advanced.defaultFluids) {
NomiLabs.LOGGER.debug("Processing Input {}", fluidName);

var fluid = masterFluidReference.get(fluidName);
if (fluid == null)
throw new IllegalArgumentException("Nomi Labs: Config Entry " + fluidName + "in Default Fluids Config doesn't exist!");
var oldFluid = fluids.get(fluid.getName());
if (oldFluid == null) continue;

var oldName = masterFluidReference.inverse().get(oldFluid);
if (oldName.equals(fluidName)) {
NomiLabs.LOGGER.debug("Default fluid of {} is already {}. Not Changing...", fluid.getName(), fluidName);
continue;
}

NomiLabs.LOGGER.debug("Changing default fluid of {}, from {} to {}.", fluid.getName(), oldName, fluidName);
changed++;

fluids.forcePut(fluid.getName(), fluid);
defaultFluidName.forcePut(fluid.getName(), fluidName);
Integer id = localFluidIDs.remove(oldFluid);
localFluidIDs.forcePut(fluid, id);
fluidNames.forcePut(id, fluid.getName());
}
if (changed == 0) {
NomiLabs.LOGGER.info("No Fluids Changed.");
return;
}
NomiLabs.LOGGER.info("Changed {} Default Fluid(s)!", changed);
fluidIDs = localFluidIDs;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.nomiceu.nomilabs.mixin.advancedrocketry;

import net.minecraft.block.Block;
import net.minecraftforge.fluids.BlockFluidBase;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import zmaster587.advancedRocketry.AdvancedRocketry;
import zmaster587.libVulpes.api.LibVulpesBlocks;

@Mixin(value = AdvancedRocketry.class, remap = false)
public class AdvancedRocketryMixin {
@Redirect(method = "registerBlocks", at = @At(value = "INVOKE", target = "Lzmaster587/libVulpes/api/LibVulpesBlocks;registerBlock(Lnet/minecraft/block/Block;)Lnet/minecraft/block/Block;"))
public <T extends Block> T registerBlocksProperly(T block) {
if (block instanceof BlockFluidBase) {
return LibVulpesBlocks.registerBlock(block, null, false);
}
return LibVulpesBlocks.registerBlock(block);
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/nomilabs/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ config.nomilabs.mod_integration=Mod Integration Settings
config.nomilabs.mod_integration.nuclearcraft=Enable NuclearCraft Integration
config.nomilabs.mod_integration.xu2=Enable Extra Utilities 2 Integration
config.nomilabs.mod_integration.top=Enable The One Probe Integration
config.nomilabs.mod_integration.advanced_rocketry=Enable Advanced Rocketry Integration
config.nomilabs.mod_integration.ender_storage=Enable Ender Storage Integration
config.nomilabs.mod_integration.ender_io=Enable Ender IO Integration

Expand All @@ -44,6 +45,7 @@ config.nomilabs.advanced.disable_xp_scaling=Disable Anvil XP Scaling
config.nomilabs.advanced.disable_advancements=Disable Advancements
config.nomilabs.advanced.disable_narrator=Disable Narrator
config.nomilabs.advanced.enable_nomi_ceu_data_fixes=Enable Nomi-CEu Specific Data Fixes
config.nomilabs.advanced.default_fluids=Default Fluids
config.nomilabs.advanced.ignore_items=ITEM Missing Registry Ignore List
config.nomilabs.advanced.ignore_blocks=BLOCK Missing Registry Ignore List
config.nomilabs.advanced.ignore_entities=ENTITY Missing Registry Ignore List
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/mixins.nomilabs.advancedrocketry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"package": "com.nomiceu.nomilabs.mixin.advancedrocketry",
"refmap": "mixins.nomilabs.refmap.json",
"target": "@env(DEFAULT)",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": [
"AdvancedRocketryMixin"
],
"client": [],
"server": []
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.nomilabs.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"mixins": [
"AdvancementListMixin",
"AdvancementManagerMixin",
"FluidRegistryMixin",
"ItemStackMixin",
"NarratorMixin",
"WorldLoadHandler"
Expand Down

0 comments on commit 6b1c70a

Please sign in to comment.