Skip to content

Commit 0ed079a

Browse files
authored
Mapper backend refactor and texture deco improvements (#280)
* mapper backend refactor & texturedeco improvements * change texture deco cache path * fixes & optimisations * reviews * fix * fix exception * remove reflection & javadocs * completions can consider all params * fix issues with custom mapper classes * spotless * fix weird bwm crash
1 parent d23ac46 commit 0ed079a

27 files changed

+852
-438
lines changed

src/main/java/com/cleanroommc/groovyscript/GroovyScript.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import com.cleanroommc.groovyscript.event.EventHandler;
1616
import com.cleanroommc.groovyscript.helper.JsonHelper;
1717
import com.cleanroommc.groovyscript.helper.StyleConstant;
18-
import com.cleanroommc.groovyscript.mapper.ObjectMapper;
18+
import com.cleanroommc.groovyscript.mapper.AbstractObjectMapper;
1919
import com.cleanroommc.groovyscript.mapper.ObjectMapperManager;
2020
import com.cleanroommc.groovyscript.network.CReload;
2121
import com.cleanroommc.groovyscript.network.NetworkHandler;
@@ -166,7 +166,7 @@ public static void initializeGroovyPreInit() {
166166
ObjectMapperManager.init();
167167
StandardInfoParserRegistry.init();
168168
ModSupport.init();
169-
for (ObjectMapper<?> goh : ObjectMapperManager.getObjectMappers()) {
169+
for (AbstractObjectMapper<?> goh : ObjectMapperManager.getObjectMappers()) {
170170
getSandbox().registerBinding(goh);
171171
}
172172
if (FMLLaunchHandler.isDeobfuscatedEnvironment()) Documentation.generate();

src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithaddons/BetterWithAddons.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@ public BetterWithAddons() {
2727
}
2828

2929
/**
30-
* Because Better With Addons checks if the ingredient is an instanceof {@link betterwithaddons.util.IHasSize IHasSize}
31-
* to determine if the Ingredient has an amount, we have to use their custom Ingredient.
32-
* <p>
33-
* If this isn't used, then the recipe may appear correctly in JEI but will actually only consume 1 when done in-game.
30+
* This is required for grs to not crash when bwm is not loaded for some reason.
3431
*/
35-
public static Ingredient fromIIngredient(IIngredient ingredient) {
36-
return new IngredientSized(ingredient.toMcIngredient(), ingredient.getAmount());
32+
public static class FromIngredient {
33+
34+
/**
35+
* Because Better With Addons checks if the ingredient is an instanceof {@link betterwithaddons.util.IHasSize IHasSize}
36+
* to determine if the Ingredient has an amount, we have to use their custom Ingredient.
37+
* <p>
38+
* If this isn't used, then the recipe may appear correctly in JEI but will actually only consume 1 when done in-game.
39+
*/
40+
public static Ingredient fromIIngredient(IIngredient ingredient) {
41+
return new IngredientSized(ingredient.toMcIngredient(), ingredient.getAmount());
42+
}
3743
}
3844

3945
public static boolean isBetterWithEverything() {

src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithaddons/DryingBox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void validate(GroovyLog.Msg msg) {
7777
@RecipeBuilderRegistrationMethod
7878
public @Nullable CherryBoxRecipe register() {
7979
if (!validate()) return null;
80-
CherryBoxRecipe recipe = new CherryBoxRecipe(BlockCherryBox.CherryBoxType.DRYING, BetterWithAddons.fromIIngredient(input.get(0)), output.get(0));
80+
CherryBoxRecipe recipe = new CherryBoxRecipe(BlockCherryBox.CherryBoxType.DRYING, BetterWithAddons.FromIngredient.fromIIngredient(input.get(0)), output.get(0));
8181
ModSupport.BETTER_WITH_ADDONS.get().dryingBox.add(recipe);
8282
return recipe;
8383
}

src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithaddons/FireNet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void validate(GroovyLog.Msg msg) {
7878
@RecipeBuilderRegistrationMethod
7979
public @Nullable NetRecipe register() {
8080
if (!validate()) return null;
81-
NetRecipe recipe = new NetRecipe(BlockNettedScreen.SifterType.FIRE, BetterWithAddons.fromIIngredient(input.get(0)), 0, output.toArray(new ItemStack[0]));
81+
NetRecipe recipe = new NetRecipe(BlockNettedScreen.SifterType.FIRE, BetterWithAddons.FromIngredient.fromIIngredient(input.get(0)), 0, output.toArray(new ItemStack[0]));
8282
ModSupport.BETTER_WITH_ADDONS.get().fireNet.add(recipe);
8383
return recipe;
8484
}

src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithaddons/Packing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void validate(GroovyLog.Msg msg) {
8585
@RecipeBuilderRegistrationMethod
8686
public @Nullable PackingRecipe register() {
8787
if (!validate()) return null;
88-
PackingRecipe recipe = new PackingRecipe(BetterWithAddons.fromIIngredient(input.get(0)), compress);
88+
PackingRecipe recipe = new PackingRecipe(BetterWithAddons.FromIngredient.fromIIngredient(input.get(0)), compress);
8989
recipe.setJeiOutput(IngredientHelper.isEmpty(jeiOutput) ? IngredientHelper.toItemStack(compress) : jeiOutput);
9090
ModSupport.BETTER_WITH_ADDONS.get().packing.add(recipe);
9191
return recipe;

src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithaddons/SandNet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void validate(GroovyLog.Msg msg) {
9191
@RecipeBuilderRegistrationMethod
9292
public @Nullable NetRecipe register() {
9393
if (!validate()) return null;
94-
NetRecipe recipe = new NetRecipe(BlockNettedScreen.SifterType.SAND, BetterWithAddons.fromIIngredient(input.get(0)), sand, output.toArray(new ItemStack[0]));
94+
NetRecipe recipe = new NetRecipe(BlockNettedScreen.SifterType.SAND, BetterWithAddons.FromIngredient.fromIIngredient(input.get(0)), sand, output.toArray(new ItemStack[0]));
9595
ModSupport.BETTER_WITH_ADDONS.get().sandNet.add(recipe);
9696
return recipe;
9797
}

src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithaddons/SoakingBox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void validate(GroovyLog.Msg msg) {
7777
@RecipeBuilderRegistrationMethod
7878
public @Nullable CherryBoxRecipe register() {
7979
if (!validate()) return null;
80-
CherryBoxRecipe recipe = new CherryBoxRecipe(BlockCherryBox.CherryBoxType.SOAKING, BetterWithAddons.fromIIngredient(input.get(0)), output.get(0));
80+
CherryBoxRecipe recipe = new CherryBoxRecipe(BlockCherryBox.CherryBoxType.SOAKING, BetterWithAddons.FromIngredient.fromIIngredient(input.get(0)), output.get(0));
8181
ModSupport.BETTER_WITH_ADDONS.get().soakingBox.add(recipe);
8282
return recipe;
8383
}

src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithaddons/Spindle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void validate(GroovyLog.Msg msg) {
8787
@RecipeBuilderRegistrationMethod
8888
public @Nullable SpindleRecipe register() {
8989
if (!validate()) return null;
90-
SpindleRecipe recipe = new SpindleRecipe(popoff, BetterWithAddons.fromIIngredient(input.get(0)), output.toArray(new ItemStack[0]));
90+
SpindleRecipe recipe = new SpindleRecipe(popoff, BetterWithAddons.FromIngredient.fromIIngredient(input.get(0)), output.toArray(new ItemStack[0]));
9191
ModSupport.BETTER_WITH_ADDONS.get().spindle.add(recipe);
9292
return recipe;
9393
}

src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithaddons/Tatara.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void validate(GroovyLog.Msg msg) {
7676
@RecipeBuilderRegistrationMethod
7777
public @Nullable SmeltingRecipe register() {
7878
if (!validate()) return null;
79-
SmeltingRecipe recipe = new SmeltingRecipe(BetterWithAddons.fromIIngredient(input.get(0)), output.get(0));
79+
SmeltingRecipe recipe = new SmeltingRecipe(BetterWithAddons.FromIngredient.fromIIngredient(input.get(0)), output.get(0));
8080
ModSupport.BETTER_WITH_ADDONS.get().tatara.add(recipe);
8181
return recipe;
8282
}

src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithaddons/Transmutation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void validate(GroovyLog.Msg msg) {
8686
@RecipeBuilderRegistrationMethod
8787
public @Nullable TransmutationRecipe register() {
8888
if (!validate()) return null;
89-
TransmutationRecipe recipe = new TransmutationRecipe(BetterWithAddons.fromIIngredient(input.get(0)), spirits, output.get(0));
89+
TransmutationRecipe recipe = new TransmutationRecipe(BetterWithAddons.FromIngredient.fromIIngredient(input.get(0)), spirits, output.get(0));
9090
ModSupport.BETTER_WITH_ADDONS.get().transmutation.add(recipe);
9191
return recipe;
9292
}

0 commit comments

Comments
 (0)