Skip to content

Commit c58113f

Browse files
committed
Update and enable EMI in dev
1 parent 586c3ea commit c58113f

File tree

8 files changed

+42
-27
lines changed

8 files changed

+42
-27
lines changed

build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ idea {
4242
}
4343

4444
ext {
45-
versionProperties = ["version" : mod_version, "mc_version": minecraft_version_range, "forge_version": forge_version_range, "loader_version": loader_version_range,
46-
"emi_version": emi_version_range]
45+
versionProperties = ["version" : mod_version, "mc_version": minecraft_version_range, "forge_version": forge_version_range, "loader_version": loader_version_range]
4746
jsonPatterns = ["**/*.json", "**/*.mcmeta"]
4847
secondaryModules = ['additions', 'defense', 'generators', 'tools']
4948
extraTypes = ['datagen']
@@ -432,10 +431,10 @@ dependencies {
432431
//runtimeOnly("mezz.jei:jei-${previous_minor_minecraft_version}-neoforge:${jei_version}")
433432
}
434433

435-
compileOnly("dev.emi:emi-neoforge:${emi_version}+${previous_minor_minecraft_version}:api")
434+
compileOnly("dev.emi:emi-neoforge:${emi_version}+${minecraft_version}:api")
436435

437436
if (recipe_viewer == "emi" || recipe_viewer == "hybrid") {
438-
runtimeOnly("dev.emi:emi-neoforge:${emi_version}+${previous_minor_minecraft_version}")
437+
runtimeOnly("dev.emi:emi-neoforge:${emi_version}+${minecraft_version}")
439438
}
440439

441440
//TODO - 1.19: Re-enable once https://github.com/Chisel-Team/ConnectedTexturesMod/pull/204 is merged

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ neogradle.subsystems.parchment.mappingsVersion=2024.02.25
2828

2929
#misc settings
3030
# recipe viewer, currently accepts: jei, emi, hybrid
31-
recipe_viewer=jei
31+
recipe_viewer=emi
3232

3333
#datagen
3434
yamlops_version=1.2.0
3535

3636
#Mod dependencies
3737
crafttweaker_version=17.0.3
3838
curios_version=7.3.4+1.20.4
39-
emi_version=1.1.4
39+
emi_version=1.1.6
4040
jade_api_id=5111969
4141
jade_id=5109393
4242
jei_version=17.3.0.49
@@ -45,7 +45,7 @@ top_version=1.20.4_neo-11.0.1-2
4545
wthit_version=10.4.0
4646

4747
#Mod dependency min version ranges
48-
emi_version_range=[1.1.4,)
48+
4949

5050
#Mod dependency min version ranges until next MC version. For deps that we need a min version of but otherwise don't have to force ourselves loading after
5151

src/main/java/mekanism/client/recipe_viewer/emi/ChemicalEmiIngredientSerializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import mekanism.api.annotations.NothingNullByDefault;
77
import mekanism.api.chemical.Chemical;
88
import net.minecraft.core.Registry;
9-
import net.minecraft.nbt.CompoundTag;
9+
import net.minecraft.core.component.DataComponentPatch;
1010
import net.minecraft.resources.ResourceLocation;
1111

1212
@NothingNullByDefault
@@ -27,7 +27,7 @@ public EmiStack create(CHEMICAL chemical) {
2727
}
2828

2929
@Override
30-
public EmiStack create(ResourceLocation id, CompoundTag nbt, long amount) {
30+
public EmiStack create(ResourceLocation id, DataComponentPatch ignored, long amount) {
3131
Optional<CHEMICAL> chemical = registry.getOptional(id).filter(c -> !c.isEmptyType());
3232
if (chemical.isPresent()) {
3333
return stackCreator.create(chemical.get(), amount);

src/main/java/mekanism/client/recipe_viewer/emi/ChemicalEmiStack.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import net.minecraft.client.gui.GuiGraphics;
2525
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
2626
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
27+
import net.minecraft.core.component.DataComponentPatch;
2728
import net.minecraft.nbt.CompoundTag;
2829
import net.minecraft.network.chat.Component;
2930
import net.minecraft.resources.ResourceLocation;
@@ -82,10 +83,9 @@ public boolean isEmpty() {
8283
return chemical.isEmptyType() || amount == 0;
8384
}
8485

85-
@Nullable
8686
@Override
87-
public CompoundTag getNbt() {
88-
return null;
87+
public DataComponentPatch getComponentChanges() {
88+
return DataComponentPatch.EMPTY;
8989
}
9090

9191
@Override
@@ -145,6 +145,10 @@ public static ChemicalEmiStack<?> create(Chemical<?> chemical, long amount) {
145145

146146
public static class GasEmiStack extends ChemicalEmiStack<Gas> {
147147

148+
public GasEmiStack(Gas gas, DataComponentPatch ignored, long amount) {
149+
this(gas, amount);
150+
}
151+
148152
public GasEmiStack(Gas gas, long amount) {
149153
super(gas, amount);
150154
}
@@ -157,6 +161,10 @@ protected GasEmiStack construct(Gas gas, long amount) {
157161

158162
public static class InfusionEmiStack extends ChemicalEmiStack<InfuseType> {
159163

164+
public InfusionEmiStack(InfuseType infuseType, DataComponentPatch ignored, long amount) {
165+
this(infuseType, amount);
166+
}
167+
160168
public InfusionEmiStack(InfuseType infuseType, long amount) {
161169
super(infuseType, amount);
162170
}
@@ -169,6 +177,10 @@ protected InfusionEmiStack construct(InfuseType infuseType, long amount) {
169177

170178
public static class PigmentEmiStack extends ChemicalEmiStack<Pigment> {
171179

180+
public PigmentEmiStack(Pigment pigment, DataComponentPatch ignored, long amount) {
181+
this(pigment, amount);
182+
}
183+
172184
public PigmentEmiStack(Pigment pigment, long amount) {
173185
super(pigment, amount);
174186
}
@@ -181,6 +193,10 @@ protected PigmentEmiStack construct(Pigment pigment, long amount) {
181193

182194
public static class SlurryEmiStack extends ChemicalEmiStack<Slurry> {
183195

196+
public SlurryEmiStack(Slurry slurry, DataComponentPatch ignored, long amount) {
197+
this(slurry, amount);
198+
}
199+
184200
public SlurryEmiStack(Slurry slurry, long amount) {
185201
super(slurry, amount);
186202
}

src/main/java/mekanism/client/recipe_viewer/emi/EmiGhostIngredientHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ private static Object getFirstSupportedStack(IGhostIngredientConsumer handler, E
5252
if (emiStack.getKey() instanceof Item) {
5353
raw = emiStack.getItemStack();
5454
} else if (emiStack.getKey() instanceof Fluid fluid) {
55-
//TODO - 1.20.5: Components
56-
raw = new FluidStack(fluid, FluidType.BUCKET_VOLUME);
55+
raw = new FluidStack(fluid.builtInRegistryHolder(), FluidType.BUCKET_VOLUME, emiStack.getComponentChanges());
5756
} else if (emiStack.getKey() instanceof Chemical<?> chemical) {
5857
raw = chemical.getStack(emiStack.getAmount());
5958
}

src/main/java/mekanism/client/recipe_viewer/emi/MekanismEmi.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import dev.emi.emi.api.recipe.VanillaEmiRecipeCategories;
1010
import dev.emi.emi.api.stack.Comparison;
1111
import dev.emi.emi.api.stack.EmiIngredient;
12+
import dev.emi.emi.api.stack.EmiRegistryAdapter;
1213
import dev.emi.emi.api.stack.EmiStack;
1314
import java.util.ArrayList;
1415
import java.util.Collection;
@@ -98,26 +99,30 @@ public class MekanismEmi implements EmiPlugin {
9899

99100
@SuppressWarnings("Convert2Diamond")//Can't be detected properly
100101
private static final ChemicalEmiIngredientSerializer<Gas, GasEmiStack> GAS_SERIALIZER = new ChemicalEmiIngredientSerializer<Gas, GasEmiStack>("Gas", MekanismAPI.GAS_REGISTRY, GasEmiStack::new);
102+
private static final EmiRegistryAdapter<Gas> GAS_REGISTRY_ADAPTER = EmiRegistryAdapter.simple(Gas.class, MekanismAPI.GAS_REGISTRY, GasEmiStack::new);
101103
@SuppressWarnings("Convert2Diamond")//Can't be detected properly
102104
private static final ChemicalEmiIngredientSerializer<InfuseType, InfusionEmiStack> INFUSION_SERIALIZER = new ChemicalEmiIngredientSerializer<InfuseType, InfusionEmiStack>("Infuse Type", MekanismAPI.INFUSE_TYPE_REGISTRY, InfusionEmiStack::new);
105+
private static final EmiRegistryAdapter<InfuseType> INFUSE_TYPE_REGISTRY_ADAPTER = EmiRegistryAdapter.simple(InfuseType.class, MekanismAPI.INFUSE_TYPE_REGISTRY, InfusionEmiStack::new);
103106
@SuppressWarnings("Convert2Diamond")//Can't be detected properly
104107
private static final ChemicalEmiIngredientSerializer<Pigment, PigmentEmiStack> PIGMENT_SERIALIZER = new ChemicalEmiIngredientSerializer<Pigment, PigmentEmiStack>("Pigment", MekanismAPI.PIGMENT_REGISTRY, PigmentEmiStack::new);
108+
private static final EmiRegistryAdapter<Pigment> PIGMENT_REGISTRY_ADAPTER = EmiRegistryAdapter.simple(Pigment.class, MekanismAPI.PIGMENT_REGISTRY, PigmentEmiStack::new);
105109
@SuppressWarnings("Convert2Diamond")//Can't be detected properly
106110
private static final ChemicalEmiIngredientSerializer<Slurry, SlurryEmiStack> SLURRY_SERIALIZER = new ChemicalEmiIngredientSerializer<Slurry, SlurryEmiStack>("Slurry", MekanismAPI.SLURRY_REGISTRY, SlurryEmiStack::new);
111+
private static final EmiRegistryAdapter<Slurry> SLURRY_REGISTRY_ADAPTER = EmiRegistryAdapter.simple(Slurry.class, MekanismAPI.SLURRY_REGISTRY, SlurryEmiStack::new);
107112

108-
//TODO - 1.20.4: I believe this doesn't work because of https://github.com/emilyploszaj/emi/issues/475
109113
private static final Comparison MEKANISM_COMPARISON = Comparison.compareData(emiStack -> {
110-
ItemStack stack = emiStack.getItemStack();
111114
//TODO - 1.20.5: Re-evaluate if we want the components check or if it should check it slightly differently?
112-
if (!stack.getComponents().isEmpty()) {
115+
if (!emiStack.getComponentChanges().isEmpty()) {
113116
Set<Object> representation = new HashSet<>();
117+
ItemStack stack = emiStack.getItemStack();
114118
addChemicalComponent(representation, stack, ContainerType.GAS, Capabilities.GAS.item());
115119
addChemicalComponent(representation, stack, ContainerType.INFUSION, Capabilities.INFUSION.item());
116120
addChemicalComponent(representation, stack, ContainerType.PIGMENT, Capabilities.PIGMENT.item());
117121
addChemicalComponent(representation, stack, ContainerType.SLURRY, Capabilities.SLURRY.item());
118122
addFluidComponent(representation, stack);
119123
addEnergyComponent(representation, stack);
120124
if (!representation.isEmpty()) {
125+
121126
return representation;
122127
}
123128
}
@@ -204,7 +209,11 @@ public void initialize(EmiInitRegistry registry) {
204209
registry.addIngredientSerializer(InfusionEmiStack.class, INFUSION_SERIALIZER);
205210
registry.addIngredientSerializer(PigmentEmiStack.class, PIGMENT_SERIALIZER);
206211
registry.addIngredientSerializer(SlurryEmiStack.class, SLURRY_SERIALIZER);
207-
//TODO - 1.20.4: Add a support for tag ingredients https://github.com/emilyploszaj/emi/issues/483
212+
//TODO - 1.20.5: Test this works properly for getting things to display as tags
213+
registry.addRegistryAdapter(GAS_REGISTRY_ADAPTER);
214+
registry.addRegistryAdapter(INFUSE_TYPE_REGISTRY_ADAPTER);
215+
registry.addRegistryAdapter(PIGMENT_REGISTRY_ADAPTER);
216+
registry.addRegistryAdapter(SLURRY_REGISTRY_ADAPTER);
208217
}
209218

210219
private <CHEMICAL extends Chemical<CHEMICAL>> void addEmiStacks(EmiRegistry emiRegistry, ChemicalEmiIngredientSerializer<CHEMICAL, ?> serializer) {
@@ -217,7 +226,6 @@ private <CHEMICAL extends Chemical<CHEMICAL>> void addEmiStacks(EmiRegistry emiR
217226

218227
@Override
219228
public void register(EmiRegistry registry) {
220-
//TODO - 1.20.4: Tooltips in EMI in mekanism screens render behind the items rendered in EMI https://github.com/emilyploszaj/emi/issues/480
221229
addEmiStacks(registry, GAS_SERIALIZER);
222230
addEmiStacks(registry, INFUSION_SERIALIZER);
223231
addEmiStacks(registry, PIGMENT_SERIALIZER);

src/main/java/mekanism/client/recipe_viewer/emi/widget/MekanismTankEmiWidget.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public void drawStack(GuiGraphics graphics, int mouseX, int mouseY, float delta)
5454
MekanismRenderer.color(graphics, chemical);
5555
sprite = MekanismRenderer.getChemicalTexture(chemical);
5656
} else if (stack.getKey() instanceof Fluid fluid) {
57-
//TODO - 1.20.5: Components
58-
FluidStack fluidStack = new FluidStack(fluid, MathUtils.clampToInt(ingredient.getAmount()));
57+
FluidStack fluidStack = new FluidStack(fluid.builtInRegistryHolder(), MathUtils.clampToInt(ingredient.getAmount()), stack.getComponentChanges());
5958
MekanismRenderer.color(graphics, fluidStack);
6059
sprite = MekanismRenderer.getFluidTexture(fluidStack, FluidTextureType.STILL);
6160
} else {

src/main/resources/META-INF/neoforge.mods.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,4 @@ license="MIT"
2222
modId="neoforge"
2323
type="required"
2424
versionRange="${forge_version}"
25-
side="BOTH"
26-
[[dependencies.mekanism]]
27-
modId="emi"
28-
type="optional"
29-
versionRange="${emi_version}"
30-
ordering="AFTER"
3125
side="BOTH"

0 commit comments

Comments
 (0)