Skip to content

Commit e55ff11

Browse files
authored
Fix DEDA JEI display (#345)
1 parent 501d997 commit e55ff11

File tree

7 files changed

+95
-17
lines changed

7 files changed

+95
-17
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 2.6.1
2+
- Fix DEDA JEI display [#345](https://github.com/GTModpackTeam/GTExpert-Core/pull/345)
3+
4+
* * *
5+
16
# 2.6.0
27
- Mining Level and Tool Suitability Adjustments for Blocks Added via Chisel [#343](https://github.com/GTModpackTeam/GTExpert-Core/pull/343)
38
- DEDA Integration Refactoring [#344](https://github.com/GTModpackTeam/GTExpert-Core/pull/344)

src/main/java/com/github/gtexpert/core/api/util/GTELog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import org.apache.logging.log4j.LogManager;
44
import org.apache.logging.log4j.Logger;
55

6-
import com.github.gtexpert.core.api.GTEValues;
6+
import com.github.gtexpert.core.Tags;
77

88
public class GTELog {
99

1010
private GTELog() {}
1111

12-
public static Logger logger = LogManager.getLogger(GTEValues.MODNAME);
12+
public static Logger logger = LogManager.getLogger(Tags.MODNAME);
1313
}

src/main/java/com/github/gtexpert/core/integration/deda/recipemaps/RecipeMapDraconicUpgrade.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.jetbrains.annotations.NotNull;
44

5-
import gregtech.api.recipes.Recipe;
65
import gregtech.api.recipes.RecipeBuilder;
76
import gregtech.api.recipes.RecipeMap;
87

@@ -12,14 +11,4 @@ public RecipeMapDraconicUpgrade(@NotNull String unlocalizedName, int maxInputs,
1211
int maxFluidOutputs, @NotNull R defaultRecipeBuilder, boolean isHidden) {
1312
super(unlocalizedName, maxInputs, maxOutputs, maxFluidInputs, maxFluidOutputs, defaultRecipeBuilder, isHidden);
1413
}
15-
16-
@Override
17-
public int getPropertyHeightShift() {
18-
return super.getPropertyHeightShift() + 10;
19-
}
20-
21-
@Override
22-
public int getPropertyListHeight(Recipe recipe) {
23-
return super.getPropertyListHeight(recipe) + 10;
24-
}
2514
}

src/main/java/com/github/gtexpert/core/integration/deda/recipemaps/tierup/TierUpRecipeProperty.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ public static TierUpRecipeProperty getInstance() {
2525

2626
@Override
2727
public void drawInfo(Minecraft minecraft, int x, int y, int color, Object value) {
28-
minecraft.fontRenderer.drawString(I18n.format("recipemap.draconic_fusion_tier_up.property.1"), x, y, color);
29-
minecraft.fontRenderer.drawString(I18n.format("recipemap.draconic_fusion_tier_up.property.2"), x, y + 10,
28+
minecraft.fontRenderer.drawString(I18n.format("recipemap.draconic_fusion_tier_up.property.1"), x, y - 10,
3029
color);
30+
minecraft.fontRenderer.drawString(I18n.format("recipemap.draconic_fusion_tier_up.property.2"), x, y, color);
31+
}
32+
33+
@Override
34+
public int getInfoHeight(Object value) {
35+
return 20;
3136
}
3237
}

src/main/java/com/github/gtexpert/core/integration/deda/recipemaps/upgrade/UpgradeRecipeProperty.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ public static UpgradeRecipeProperty getInstance() {
2525

2626
@Override
2727
public void drawInfo(Minecraft minecraft, int x, int y, int color, Object value) {
28-
minecraft.fontRenderer.drawString(I18n.format("recipemap.draconic_fusion_upgrade.property.1"), x, y, color);
29-
minecraft.fontRenderer.drawString(I18n.format("recipemap.draconic_fusion_upgrade.property.2"), x, y + 10,
28+
minecraft.fontRenderer.drawString(I18n.format("recipemap.draconic_fusion_upgrade.property.1"), x, y - 10,
3029
color);
30+
minecraft.fontRenderer.drawString(I18n.format("recipemap.draconic_fusion_upgrade.property.2"), x, y, color);
31+
}
32+
33+
@Override
34+
public int getInfoHeight(Object value) {
35+
return 20;
3136
}
3237
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package com.github.gtexpert.core.mixins.gregtech;
2+
3+
import java.util.Map;
4+
5+
import org.spongepowered.asm.mixin.Final;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.Shadow;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
10+
11+
import gregtech.api.recipes.Recipe;
12+
import gregtech.api.recipes.RecipeMap;
13+
import gregtech.api.recipes.recipeproperties.RecipeProperty;
14+
import gregtech.integration.jei.recipe.GTRecipeWrapper;
15+
16+
import com.github.gtexpert.core.integration.deda.recipemaps.GTEDraconicRecipeMaps;
17+
18+
@Mixin(value = GTRecipeWrapper.class, remap = false)
19+
public class GTRecipeWrapperMixin {
20+
21+
@Shadow
22+
@Final
23+
private RecipeMap<?> recipeMap;
24+
25+
@Shadow
26+
@Final
27+
private Recipe recipe;
28+
29+
/**
30+
* Modify yPosition calculation to use actual getInfoHeight() values instead of assuming 10px per property.
31+
* Only applies to DEDA recipe maps where properties have custom heights.
32+
* Original: recipeHeight - ((recipe.getUnhiddenPropertyCount() + defaultLines) * 10 - 3)
33+
* Fixed: recipeHeight - (sumOfPropertyHeights + defaultLines * 10 - 3)
34+
*/
35+
@ModifyVariable(method = "drawInfo", at = @At(value = "STORE"), ordinal = 5)
36+
private int gteCore$fixYPosition(int original) {
37+
// Only apply fix for DEDA recipe maps
38+
if (recipeMap != GTEDraconicRecipeMaps.DRACONIC_FUSION_TIER_UP_RECIPES &&
39+
recipeMap != GTEDraconicRecipeMaps.DRACONIC_FUSION_UPGRADE_RECIPES) {
40+
return original;
41+
}
42+
43+
// Calculate defaultLines the same way as the original method
44+
var properties = recipe.getPropertyTypes();
45+
boolean drawTotalEU = properties.isEmpty() ||
46+
properties.stream().noneMatch(RecipeProperty::hideTotalEU);
47+
boolean drawEUt = properties.isEmpty() ||
48+
properties.stream().noneMatch(RecipeProperty::hideEUt);
49+
boolean drawDuration = properties.isEmpty() ||
50+
properties.stream().noneMatch(RecipeProperty::hideDuration);
51+
52+
int defaultLines = 0;
53+
if (drawTotalEU) defaultLines++;
54+
if (drawEUt) defaultLines++;
55+
if (drawDuration) defaultLines++;
56+
57+
// Reconstruct recipeHeight from original calculation:
58+
// original = recipeHeight - ((propertyCount + defaultLines) * 10 - 3)
59+
int propertyCount = recipe.getUnhiddenPropertyCount();
60+
int originalOffset = (propertyCount + defaultLines) * 10 - 3;
61+
int recipeHeight = original + originalOffset;
62+
63+
// Calculate actual property height from getInfoHeight values
64+
int actualPropertyHeight = 0;
65+
for (Map.Entry<RecipeProperty<?>, Object> entry : recipe.getPropertyValues()) {
66+
if (!entry.getKey().isHidden()) {
67+
actualPropertyHeight += entry.getKey().getInfoHeight(entry.getValue());
68+
}
69+
}
70+
71+
return recipeHeight - (actualPropertyHeight + defaultLines * 10 - 3);
72+
}
73+
}

src/main/resources/mixins.gtexpert.gregtech.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"server": [
1111
],
1212
"client": [
13+
"GTRecipeWrapperMixin"
1314
]
1415
}

0 commit comments

Comments
 (0)