Skip to content

Commit 89218a4

Browse files
committed
rei compatibility
1 parent aa2d464 commit 89218a4

File tree

5 files changed

+130
-1
lines changed

5 files changed

+130
-1
lines changed

build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ repositories {
1616
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
1717
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
1818
// for more information about repositories.
19+
maven { url "https://maven.shedaniel.me" }
1920
}
2021

2122
fabricApi {
@@ -30,7 +31,13 @@ dependencies {
3031

3132
// Fabric API. This is technically optional, but you probably want it anyway.
3233
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
33-
34+
35+
modCompileOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:16.0.777"
36+
modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:16.0.777"
37+
38+
modApi "dev.architectury:architectury-fabric:13.0.8"
39+
modApi "me.shedaniel.cloth:cloth-config-fabric:15.0.140"
40+
3441
}
3542

3643
processResources {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package net.kaupenjoe.tutorialmod.compat;
2+
3+
import me.shedaniel.math.Point;
4+
import me.shedaniel.math.Rectangle;
5+
import me.shedaniel.rei.api.client.gui.Renderer;
6+
import me.shedaniel.rei.api.client.gui.widgets.Widget;
7+
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
8+
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
9+
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
10+
import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
11+
import me.shedaniel.rei.api.common.util.EntryStacks;
12+
import net.kaupenjoe.tutorialmod.TutorialMod;
13+
import net.kaupenjoe.tutorialmod.block.ModBlocks;
14+
import net.minecraft.text.Text;
15+
import net.minecraft.util.Identifier;
16+
17+
import java.util.LinkedList;
18+
import java.util.List;
19+
20+
public class GrowthChamberCategory implements DisplayCategory<BasicDisplay> {
21+
public static final Identifier TEXTURE = Identifier.of(TutorialMod.MOD_ID,
22+
"textures/gui/growth_chamber/growth_chamber_gui.png");
23+
public static final CategoryIdentifier<GrowthChamberDisplay> GROWTH_CHAMBER =
24+
CategoryIdentifier.of(TutorialMod.MOD_ID, "growth_chamber");
25+
26+
@Override
27+
public CategoryIdentifier<? extends BasicDisplay> getCategoryIdentifier() {
28+
return GROWTH_CHAMBER;
29+
}
30+
31+
@Override
32+
public Text getTitle() {
33+
return Text.translatable("block.tutorialmod.growth_chamber");
34+
}
35+
36+
@Override
37+
public Renderer getIcon() {
38+
return EntryStacks.of(ModBlocks.GROWTH_CHAMBER.asItem().getDefaultStack());
39+
}
40+
41+
// Done with the help:
42+
// https://github.com/TeamGalacticraft/Galacticraft/tree/main (MIT License)
43+
@Override
44+
public List<Widget> setupDisplay(BasicDisplay display, Rectangle bounds) {
45+
Point startPoint = new Point(bounds.getCenterX() - 87, bounds.getCenterY() - 35);
46+
List<Widget> widgets = new LinkedList<>();
47+
48+
widgets.add(Widgets.createTexturedWidget(TEXTURE, new Rectangle(startPoint.x, startPoint.y, 175, 82)));
49+
50+
widgets.add(Widgets.createSlot(new Point(startPoint.x + 54, startPoint.y + 34))
51+
.entries(display.getInputEntries().get(0)).markInput());
52+
widgets.add(Widgets.createSlot(new Point(startPoint.x + 104, startPoint.y + 34))
53+
.entries(display.getOutputEntries().get(0)).markOutput());
54+
55+
return widgets;
56+
}
57+
58+
@Override
59+
public int getDisplayHeight() {
60+
return 90;
61+
}
62+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package net.kaupenjoe.tutorialmod.compat;
2+
3+
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
4+
import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
5+
import me.shedaniel.rei.api.common.entry.EntryIngredient;
6+
import me.shedaniel.rei.api.common.util.EntryIngredients;
7+
import me.shedaniel.rei.api.common.util.EntryStacks;
8+
import net.kaupenjoe.tutorialmod.recipe.GrowthChamberRecipe;
9+
import net.minecraft.recipe.RecipeEntry;
10+
11+
import java.util.List;
12+
13+
public class GrowthChamberDisplay extends BasicDisplay {
14+
public GrowthChamberDisplay(RecipeEntry<GrowthChamberRecipe> recipe) {
15+
super(List.of(EntryIngredients.ofIngredient(recipe.value().getIngredients().get(0))),
16+
List.of(EntryIngredient.of(EntryStacks.of(recipe.value().getResult(null)))));
17+
}
18+
19+
@Override
20+
public CategoryIdentifier<?> getCategoryIdentifier() {
21+
return GrowthChamberCategory.GROWTH_CHAMBER;
22+
}
23+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package net.kaupenjoe.tutorialmod.compat;
2+
3+
import me.shedaniel.math.Rectangle;
4+
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
5+
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
6+
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
7+
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry;
8+
import me.shedaniel.rei.api.common.util.EntryStacks;
9+
import net.kaupenjoe.tutorialmod.block.ModBlocks;
10+
import net.kaupenjoe.tutorialmod.recipe.GrowthChamberRecipe;
11+
import net.kaupenjoe.tutorialmod.recipe.ModRecipes;
12+
import net.kaupenjoe.tutorialmod.screen.custom.GrowthChamberScreen;
13+
14+
public class TutorialModREIClient implements REIClientPlugin {
15+
@Override
16+
public void registerCategories(CategoryRegistry registry) {
17+
registry.add(new GrowthChamberCategory());
18+
19+
registry.addWorkstations(GrowthChamberCategory.GROWTH_CHAMBER, EntryStacks.of(ModBlocks.GROWTH_CHAMBER));
20+
}
21+
22+
@Override
23+
public void registerDisplays(DisplayRegistry registry) {
24+
registry.registerRecipeFiller(GrowthChamberRecipe.class, ModRecipes.GROWTH_CHAMBER_TYPE,
25+
GrowthChamberDisplay::new);
26+
}
27+
28+
@Override
29+
public void registerScreens(ScreenRegistry registry) {
30+
registry.registerClickArea(screen -> new Rectangle(((screen.width - 176) / 2) + 78,
31+
((screen.height - 166) / 2) + 30, 20, 25), GrowthChamberScreen.class,
32+
GrowthChamberCategory.GROWTH_CHAMBER);
33+
}
34+
}

src/main/resources/fabric.mod.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
],
2424
"client": [
2525
"net.kaupenjoe.tutorialmod.TutorialModClient"
26+
],
27+
"rei_client": [
28+
"net.kaupenjoe.tutorialmod.compat.TutorialModREIClient"
2629
]
2730
},
2831
"mixins": [

0 commit comments

Comments
 (0)