Skip to content

Commit

Permalink
Fix GS Reload Removing All Removed Entries
Browse files Browse the repository at this point in the history
Might need to remove this (just literally revert this commit) when GS updates, if they fix it there
  • Loading branch information
IntegerLimit committed Feb 12, 2024
1 parent 9ab07ea commit e166563
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies {
implementation rfg.deobf("curse.maven:packmode-278398:2567799") // Version 1.2.0

// GroovyScript (from Cleanroom Maven)
// IF THIS IS UPDATED, THE GROOVYSCRIPT MIXIN MAY NEED TO BE REMOVED!!!
implementation ("com.cleanroommc:groovyscript:0.7.3") {
transitive = false
} // Version 0.7.3, transitive false is needed otherwise groovy pulls in extra JEI
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 @@ -17,6 +17,7 @@ public class LabsValues {
public static final String MBT_MODID = "mbt";
public static final String MULTIBLOCK_TWEAKER_MODID = "multiblocktweaker";
public static final String GREGTECH_MODID = "gregtech";
public static final String GROOVY_MODID = "groovyscript";
public static final String TOP_MODID = "theoneprobe";
public static final String ENDER_STORAGE_MODID = "enderstorage";
public static final String EXTENDED_CRAFTING_MODID = "extendedcrafting";
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/nomiceu/nomilabs/core/LabsLateMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class LabsLateMixin implements ILateMixinLoader {
new AbstractMap.SimpleImmutableEntry<>(LabsValues.GREGTECH_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.JEI_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.ROCKETRY_MODID,
LabsConfig.modIntegration.enableAdvancedRocketryIntegration))
LabsConfig.modIntegration.enableAdvancedRocketryIntegration),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.GROOVY_MODID, true))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.nomiceu.nomilabs.mixin.groovyscript;

import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager;
import mezz.jei.Internal;
import mezz.jei.ingredients.IngredientFilter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.lang.reflect.InvocationTargetException;

// TODO Might Have to Remove this in GS Update, if they fix it there?
@Mixin(value = ReloadableRegistryManager.class, remap = false)
public class ReloadableRegistryManagerMixin {
@Inject(method = "reloadJei", at = @At("TAIL"))
private static void test(boolean msgPlayer, CallbackInfo ci) {
// Fix: HEI Removals Disappearing on Reload
// Reloads the Removed Ingredients (Actually removes them)
// Must use Internal, no other way to get IngredientFilter
// Reflection, method doesn't exist in JEI
var filter = Internal.getIngredientFilter();
try {
IngredientFilter.class.getDeclaredMethod("block").invoke(filter);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ignored) {}
}
}
12 changes: 12 additions & 0 deletions src/main/resources/mixins.nomilabs.groovyscript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"package": "com.nomiceu.nomilabs.mixin.groovyscript",
"refmap": "mixins.nomilabs.refmap.json",
"target": "@env(DEFAULT)",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": [
"ReloadableRegistryManagerMixin"
],
"client": [],
"server": []
}

0 comments on commit e166563

Please sign in to comment.