Skip to content

Commit b4c0f07

Browse files
authored
Merge branch '1.21.x' into nuclearfuel-resourcelocation
2 parents 1c65645 + 4460125 commit b4c0f07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2828
-71
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ configurations {
252252
dependencies {
253253
api jarJar("dev.technici4n:GrandPower:${project.grandpower_version}")
254254

255-
compileOnly "mezz.jei:jei-${project.jei_minecraft_version}-neoforge:${project.jei_version}"
255+
compileOnly "mezz.jei:jei-${project.jei_minecraft_version}-neoforge-api:${project.jei_version}"
256256
if (project.runtime_itemlist_mod == "jei") {
257257
localRuntimeOnly "mezz.jei:jei-${project.jei_minecraft_version}-neoforge:${project.jei_version}"
258258
}

gradle.properties

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ emi_version=1.1.10
4242
ftb_quests_version=2100.1.3
4343
ftb_teams_version=2100.1.0
4444
jade_file_id=5493270
45-
jei_minecraft_version=1.21
46-
jei_version=19.8.2.99
47-
jei_version_range=[19.8.2.99,]
45+
# JEI Versions https://github.com/mezz/JustEnoughItems#1211
46+
jei_minecraft_version=1.21.1
47+
jei_version=19.20.0.241
48+
jei_version_range=[19.19.0,]
4849
kubejs_version=2100.7.0-build.102
4950
patchouli_version=1.21-87-NEOFORGE-SNAPSHOT
5051
rei_version=16.0.729
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2020 Azercoco & Technici4n
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package aztech.modern_industrialization.compat.viewer.impl.jei;
25+
26+
import aztech.modern_industrialization.compat.viewer.abstraction.ViewerCategory;
27+
import mezz.jei.api.gui.drawable.IDrawable;
28+
import mezz.jei.api.helpers.IGuiHelper;
29+
import net.minecraft.client.gui.GuiGraphics;
30+
31+
public class DrawableIcon implements IDrawable {
32+
private final ViewerCategory.Icon.Texture texture;
33+
34+
public static IDrawable create(IGuiHelper guiHelper, ViewerCategory.Icon icon) {
35+
return switch (icon) {
36+
case ViewerCategory.Icon.Stack stack -> guiHelper.createDrawableItemStack(stack.stack());
37+
case ViewerCategory.Icon.Texture texture -> new DrawableIcon(texture);
38+
case null -> throw new NullPointerException("Icon cannot be null");
39+
};
40+
}
41+
42+
public DrawableIcon(ViewerCategory.Icon.Texture texture) {
43+
this.texture = texture;
44+
}
45+
46+
@Override
47+
public int getWidth() {
48+
return 18;
49+
}
50+
51+
@Override
52+
public int getHeight() {
53+
return 18;
54+
}
55+
56+
@Override
57+
public void draw(GuiGraphics guiGraphics, int xOffset, int yOffset) {
58+
guiGraphics.blit(texture.loc(), xOffset - 1, yOffset - 1, 0, texture.u(), texture.v(), 18, 18, 256, 256);
59+
}
60+
}

src/client/java/aztech/modern_industrialization/compat/viewer/impl/jei/ViewerCategoryJei.java

Lines changed: 24 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@
3838
import mezz.jei.api.gui.builder.ITooltipBuilder;
3939
import mezz.jei.api.gui.drawable.IDrawable;
4040
import mezz.jei.api.gui.drawable.IDrawableStatic;
41-
import mezz.jei.api.gui.ingredient.IRecipeSlotTooltipCallback;
42-
import mezz.jei.api.gui.ingredient.IRecipeSlotView;
4341
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
4442
import mezz.jei.api.helpers.IJeiHelpers;
4543
import mezz.jei.api.recipe.IFocusGroup;
4644
import mezz.jei.api.recipe.RecipeIngredientRole;
4745
import mezz.jei.api.recipe.RecipeType;
48-
import mezz.jei.api.recipe.category.IRecipeCategory;
46+
import mezz.jei.api.recipe.category.AbstractRecipeCategory;
4947
import net.minecraft.client.Minecraft;
5048
import net.minecraft.client.gui.GuiGraphics;
5149
import net.minecraft.network.chat.Component;
@@ -56,58 +54,26 @@
5654
import net.neoforged.neoforge.fluids.FluidType;
5755
import org.jetbrains.annotations.Nullable;
5856

59-
class ViewerCategoryJei<D> implements IRecipeCategory<D> {
57+
class ViewerCategoryJei<D> extends AbstractRecipeCategory<D> {
6058
private final IJeiHelpers helpers;
6159
public final ViewerCategory<D> wrapped;
6260
public final RecipeType<D> recipeType;
63-
private final IDrawable background, icon, itemSlot, fluidSlot;
61+
private final IDrawable fluidSlot;
6462

6563
public ViewerCategoryJei(IJeiHelpers helpers, ViewerCategory<D> wrapped) {
64+
super(
65+
RecipeType.create(wrapped.id.getNamespace(), wrapped.id.getPath(), wrapped.dataClass),
66+
wrapped.title,
67+
DrawableIcon.create(helpers.getGuiHelper(), wrapped.icon),
68+
wrapped.width - 8,
69+
wrapped.height - 8);
70+
6671
this.helpers = helpers;
6772
this.wrapped = wrapped;
6873
this.recipeType = RecipeType.create(wrapped.id.getNamespace(), wrapped.id.getPath(), wrapped.dataClass);
6974

70-
this.background = helpers.getGuiHelper().createBlankDrawable(wrapped.width - 8, wrapped.height - 8);
71-
this.icon = wrapped.icon instanceof ViewerCategory.Icon.Stack stack ? helpers.getGuiHelper().createDrawableItemStack(stack.stack())
72-
: new IDrawable() {
73-
@Override
74-
public int getWidth() {
75-
return 18;
76-
}
77-
78-
@Override
79-
public int getHeight() {
80-
return 18;
81-
}
82-
83-
@Override
84-
public void draw(GuiGraphics guiGraphics, int xOffset, int yOffset) {
85-
var texture = (ViewerCategory.Icon.Texture) wrapped.icon;
86-
guiGraphics.blit(texture.loc(), xOffset - 1, yOffset - 1, 0, texture.u(), texture.v(), 18, 18, 256, 256);
87-
}
88-
};
89-
this.itemSlot = helpers.getGuiHelper().getSlotDrawable();
90-
this.fluidSlot = helpers.getGuiHelper().createDrawable(MachineScreen.SLOT_ATLAS, 18, 0, 18, 18);
91-
}
92-
93-
@Override
94-
public RecipeType<D> getRecipeType() {
95-
return recipeType;
96-
}
97-
98-
@Override
99-
public Component getTitle() {
100-
return wrapped.title;
101-
}
102-
103-
@Override
104-
public IDrawable getBackground() {
105-
return background;
106-
}
107-
108-
@Override
109-
public IDrawable getIcon() {
110-
return icon;
75+
var guiHelper = helpers.getGuiHelper();
76+
this.fluidSlot = guiHelper.createDrawable(MachineScreen.SLOT_ATLAS, 18, 0, 18, 18);
11177
}
11278

11379
@Override
@@ -130,8 +96,9 @@ public void invisibleOutput(ItemStack stack) {
13096
}
13197

13298
private ViewerCategory.SlotBuilder slot(RecipeIngredientRole role, int x, int y) {
133-
var slotBuilder = builder.addSlot(role, x - 4, y - 4);
134-
slotBuilder.setBackground(itemSlot, -1, -1);
99+
var slotBuilder = builder.addSlot(role, x - 4, y - 4)
100+
.setStandardSlotBackground();
101+
135102
return new ViewerCategory.SlotBuilder() {
136103
@Override
137104
public ViewerCategory.SlotBuilder variant(TransferVariant<?> variant) {
@@ -150,23 +117,11 @@ public ViewerCategory.SlotBuilder variant(TransferVariant<?> variant) {
150117
}
151118

152119
private static void addProbability(IRecipeSlotBuilder slot, float probability) {
153-
slot.addTooltipCallback(new IRecipeSlotTooltipCallback() {
154-
@Override
155-
public void onTooltip(IRecipeSlotView recipeSlotView, List<Component> tooltip) {
156-
var input = recipeSlotView.getRole() == RecipeIngredientRole.INPUT;
157-
var probabilityLine = ViewerUtil.getProbabilityTooltip(probability, input);
158-
if (probabilityLine != null) {
159-
tooltip.add(probabilityLine);
160-
}
161-
}
162-
163-
@Override
164-
public void onRichTooltip(IRecipeSlotView recipeSlotView, ITooltipBuilder tooltip) {
165-
var input = recipeSlotView.getRole() == RecipeIngredientRole.INPUT;
166-
var probabilityLine = ViewerUtil.getProbabilityTooltip(probability, input);
167-
if (probabilityLine != null) {
168-
tooltip.add(probabilityLine);
169-
}
120+
slot.addRichTooltipCallback((recipeSlotView, tooltip) -> {
121+
var input = recipeSlotView.getRole() == RecipeIngredientRole.INPUT;
122+
var probabilityLine = ViewerUtil.getProbabilityTooltip(probability, input);
123+
if (probabilityLine != null) {
124+
tooltip.add(probabilityLine);
170125
}
171126
});
172127
}
@@ -218,6 +173,7 @@ public ViewerCategory.SlotBuilder markCatalyst() {
218173

219174
@Override
220175
public void draw(D recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) {
176+
guiGraphics.pose().pushPose();
221177
guiGraphics.pose().translate(-4, -4, 0);
222178

223179
wrapped.buildWidgets(recipe, new ViewerCategory.WidgetList() {
@@ -254,7 +210,7 @@ public void drawable(Consumer<GuiGraphics> widget) {
254210
@Override
255211
public void item(double x, double y, double w, double h, ItemLike item) {
256212
guiGraphics.pose().pushPose();
257-
var drawable = helpers.getGuiHelper().createDrawableItemStack(item.asItem().getDefaultInstance());
213+
var drawable = helpers.getGuiHelper().createDrawableItemLike(item);
258214
guiGraphics.pose().translate(x, y, 0);
259215
guiGraphics.pose().scale((float) w / 16, (float) h / 16, 0);
260216
drawable.draw(guiGraphics);
@@ -265,6 +221,8 @@ public void item(double x, double y, double w, double h, ItemLike item) {
265221
public void tooltip(int x, int y, int w, int h, List<Component> tooltip) {
266222
}
267223
});
224+
225+
guiGraphics.pose().popPose();
268226
}
269227

270228
@Override

src/main/java/aztech/modern_industrialization/thirdparty/fabrictransfer/impl/fluid/FluidVariantImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static FluidVariant of(FluidStack stack) {
6868
if (stack.isComponentsPatchEmpty() || stack.isEmpty()) {
6969
return of(stack.getFluid());
7070
} else {
71-
return of(stack);
71+
return new FluidVariantImpl(stack);
7272
}
7373
}
7474

0 commit comments

Comments
 (0)