Skip to content

Commit

Permalink
emi plugin!
Browse files Browse the repository at this point in the history
  • Loading branch information
ghasto69 committed Sep 18, 2023
1 parent 69dfbfe commit d1eb323
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 39 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ dependencies {
switch (recipe_viewer.toLowerCase(Locale.ROOT)) {
case "jei": modLocalRuntime("mezz.jei:jei-${minecraft_version}-fabric:${jei_version}"); break
case "rei": modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:${rei_version}"); break
case "emi": modLocalRuntime("dev.emi:emi:${emi_version}"); break
case "emi": modLocalRuntime("maven.modrinth:emi:${emi_version}"); break
case "disabled": break
default: println("Unknown recipe viewer specified: ${recipe_viewer}. Must be JEI, REI, EMI, or disabled.")
}
Expand All @@ -86,7 +86,7 @@ dependencies {
// modCompileOnly("mezz.jei:jei-${minecraft_version}-common:${jei_fabric_version}")
// modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${rei_version}")
// modCompileOnly("me.shedaniel:RoughlyEnoughItems-default-plugin-fabric:${rei_version}")
// modCompileOnly("dev.emi:emi:${emi_version}")
modCompileOnly("maven.modrinth:emi:${emi_version}")
}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ create_version = 0.5.1-d-build.1161+mc1.20.1
# Development QOL
# Create supports all 3 recipe viewers: JEI, REI, and EMI. This decides which is enabled at runtime.
# set to disabled to have none of them.
recipe_viewer = unspecified
recipe_viewer = EMI
# JEI - https://www.curseforge.com/minecraft/mc-mods/jei/files/all
jei_version = 10.2.1.283
# REI - https://modrinth.com/mod/roughly-enough-items/versions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// 1.20.1 2023-09-13T17:58:50.441746 Create: Sandpaper Overhaul/Registrate Provider for create_so [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
a76ce33ae00a27baa4eda76f326d69a50809204b assets/create_so/lang/en_ud.json
// 1.20.1 2023-09-18T20:20:22.193453 Create: Sandpaper Overhaul/Registrate Provider for create_so [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
e6ba883012056e1b704e624d4e701edbbab0ed13 assets/create_so/lang/en_ud.json
09b7b42ebfd951db23d40928f784e8b9ffb2bcfa data/create_so/advancements/recipes/tools/iron_sandpaper.json
5fa8e37f2719558a26122cd719a8569f95f760b8 assets/create_so/models/item/unrefined_lapis_lazuli.json
6183056b14f9697590050c3fdc9838f6fe53edab data/create_so/advancements/recipes/tools/obsidian_sandpaper.json
f71c982c977c60dff1cb08121771916c65ecafc4 data/create_so/recipes/diamond_sandpaper.json
7f6d4ac0158bf800d2e475f0f31a866c0fa9a5d4 assets/create_so/lang/en_us.json
5c24317d7718425982a7f198403295eca793e619 assets/create_so/lang/en_us.json
004a6c2036ca80aa4361135b506081b19b0d1b99 data/create/tags/items/sandpaper.json
6e0ac9b9da4ee33f9cd036698d812e0d53d743d9 data/create_so/loot_tables/blocks/polishing_wheel.json
6e8fdee69adadc74221e1c65308fd32467b7a471 data/create_so/advancements/recipes/tools/diamond_sandpaper.json
Expand All @@ -17,5 +17,5 @@ f064f582da2fe48dc732ea7edabd0c72a1579dcc data/minecraft/tags/blocks/mineable/pic
4b0e51a1c10685f7d432467339afc9c2e24793b0 assets/create_so/blockstates/polishing_wheel_controller.json
22866fa23344eda3baad5a317080e7112fb88ba9 assets/create_so/blockstates/polishing_wheel.json
777f0bef0990a81f8662e071fb40478ef9ac098f assets/create_so/models/item/crushed_iron.json
b69fee687ce4c8ef34426bee57f9ff5b6a3dd6e3 assets/create_so/models/item/diamond_sandpaper.json
1de3f1f90c293f68de1ffd59e4489073ccba053e assets/create_so/models/item/crushed_diamonds.json
b69fee687ce4c8ef34426bee57f9ff5b6a3dd6e3 assets/create_so/models/item/diamond_sandpaper.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.1 2023-09-13T17:58:50.441093 Create: Sandpaper Overhaul/Create Sandpaper Overhaul's Damage Type Data
// 1.20.1 2023-09-18T20:20:22.192754 Create: Sandpaper Overhaul/Create Sandpaper Overhaul's Damage Type Data
132c7d6042e5e957f5eebe5fdbbb2dcd39c07ff7 data/create_so/damage_type/sandpaper.json
1 change: 1 addition & 0 deletions src/generated/resources/assets/create_so/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"block.create_so.polishing_wheel.tooltip.summary": "˙sʇunoɯɐ ǝbɹɐן uı sɯǝʇı ‾ɥsıןoԀ‾ uɐɔ ʇɐɥʇ ‾ןǝǝɥM buıɥsnɹƆ‾ ǝɥʇ oʇ ɹɐןıɯıs ʞɔoןq ɐ sı ‾ןǝǝɥM buıɥsıןoԀ‾ ǝɥ⟘",
"block.create_so.polishing_wheel_controller": "ɹǝןןoɹʇuoƆ ןǝǝɥM buıɥsıןoԀ",
"death.attack.create_so.sandpaper": "ɹǝdɐdpuɐs ɐ ɥʇıʍ ɥʇɐǝp oʇ pǝqqnɹɔs ʎןןɐʇnɹq sɐʍ %1$s",
"emi.category.create_so.polishing": "sןǝǝɥM buıɥsıןoԀ",
"item.create.powdered_obsidian": "uɐıpısqO pǝɥsnɹƆ",
"item.create_so.crushed_diamonds": "spuoɯɐıᗡ pǝɥsnɹƆ",
"item.create_so.crushed_iron": "uoɹI pǝɥsnɹƆ",
Expand Down
1 change: 1 addition & 0 deletions src/generated/resources/assets/create_so/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"block.create_so.polishing_wheel.tooltip.summary": "The _Polishing Wheel_ is a block similar to the _Crushing Wheel_ that can _Polish_ items in large amounts.",
"block.create_so.polishing_wheel_controller": "Polishing Wheel Controller",
"death.attack.create_so.sandpaper": "%1$s was brutally scrubbed to death with a sandpaper",
"emi.category.create_so.polishing": "Polishing Wheels",
"item.create.powdered_obsidian": "Crushed Obsidian",
"item.create_so.crushed_diamonds": "Crushed Diamonds",
"item.create_so.crushed_iron": "Crushed Iron",
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/ghasto/create_so/ModCustomLangEntries.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class ModCustomLangEntries {
lang("item.create_so.obsidian_sandpaper.tooltip.condition1", "When Used");
lang("item.create_so.obsidian_sandpaper.tooltip.behaviour1", "Applies polish to items held in the _offhand_ or lying on the _floor_ when _looking at them_");

//Emi
lang("emi.category.create_so.polishing", "Polishing Wheels");

//Misc
lang("item.create.powdered_obsidian", "Crushed Obsidian");
}
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/com/ghasto/create_so/compat/emi/ModEMICompat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.ghasto.create_so.compat.emi;

import com.ghasto.create_so.CreateSandpaperOverhaul;
import com.ghasto.create_so.ModBlocks;
import com.ghasto.create_so.ModRecipeTypes;
import com.ghasto.create_so.content.polishing_wheel.PolishingRecipe;
import com.simibubi.create.AllItems;
import com.simibubi.create.compat.emi.DoubleItemIcon;
import dev.emi.emi.api.EmiPlugin;
import dev.emi.emi.api.EmiRegistry;
import dev.emi.emi.api.recipe.EmiRecipeCategory;
import dev.emi.emi.api.render.EmiRenderable;
import dev.emi.emi.api.stack.EmiStack;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.RecipeManager;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class ModEMICompat implements EmiPlugin {
public static final Map<ResourceLocation, EmiRecipeCategory> ALL = new LinkedHashMap<>();
public static final EmiRecipeCategory
POLISHING = register("polishing", DoubleItemIcon.of(ModBlocks.POLISHING_WHEEL.get(), AllItems.SAND_PAPER.get()));
@Override
public void register(EmiRegistry registry) {
ALL.forEach((id, category) -> registry.addCategory(category));
registry.addWorkstation(POLISHING, EmiStack.of(ModBlocks.POLISHING_WHEEL.get()));
RecipeManager manager = registry.getRecipeManager();
List<PolishingRecipe> polishingRecipes = (List<PolishingRecipe>) (List) manager.getAllRecipesFor(ModRecipeTypes.POLISHING.getType());
for (PolishingRecipe recipe : polishingRecipes) {
registry.addRecipe(new PolishingEmiRecipe(recipe));
}
}
private static EmiRecipeCategory register(String name, EmiRenderable icon) {
ResourceLocation id = CreateSandpaperOverhaul.id(name);
EmiRecipeCategory category = new EmiRecipeCategory(id, icon);
ALL.put(id, category);
return category;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.ghasto.create_so.compat.emi;

import com.ghasto.create_so.ModBlocks;
import com.mojang.blaze3d.vertex.PoseStack;
import dev.emi.emi.api.widget.WidgetHolder;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;

import static com.simibubi.create.compat.emi.CreateEmiAnimations.blockElement;
import static com.simibubi.create.compat.emi.CreateEmiAnimations.getCurrentAngle;

public class ModEmiAnimations {
private static final BlockState WHEEL = ModBlocks.POLISHING_WHEEL.getDefaultState().setValue(BlockStateProperties.AXIS, Direction.Axis.X);
public static void addPolishingWheels(WidgetHolder widgets, int x, int y) {
widgets.addDrawable(x, y, 0, 0, (graphics, mouseX, mouseY, delta) -> {
PoseStack matrices = graphics.pose();
matrices.translate(0, 0, 100);
matrices.mulPose(com.mojang.math.Axis.YP.rotationDegrees(-22.5f));
int scale = 22;

blockElement(WHEEL)
.rotateBlock(0, 90, -getCurrentAngle())
.scale(scale)
.render(graphics);

blockElement(WHEEL)
.rotateBlock(0, 90, getCurrentAngle())
.atLocal(2, 0, 0)
.scale(scale)
.render(graphics);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.ghasto.create_so.compat.emi;

import com.ghasto.create_so.content.polishing_wheel.PolishingRecipe;
import com.simibubi.create.compat.emi.recipes.CreateEmiRecipe;
import com.simibubi.create.content.kinetics.crusher.AbstractCrushingRecipe;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import dev.emi.emi.api.widget.WidgetHolder;
import net.minecraft.resources.ResourceLocation;

public class PolishingEmiRecipe extends CreateEmiRecipe<AbstractCrushingRecipe> {

public PolishingEmiRecipe(PolishingRecipe recipe) {
super(ModEMICompat.POLISHING, recipe, 134, 110);
ResourceLocation rid = recipe.getId();
this.id = new ResourceLocation("emi", "create_so/polishing/" + rid.getNamespace() + "/" + rid.getPath());
}

@Override
public void addWidgets(WidgetHolder widgets) {
addTexture(widgets, AllGuiTextures.JEI_DOWN_ARROW, 51, 11);

addSlot(widgets, input.get(0), 29, 6);

int xOff = -output.size() * 19 / 2;
for (int i = 0; i < output.size(); i++) {
addSlot(widgets, output.get(i), 67 + xOff + 19 * i, 82).recipeContext(this);
}

ModEmiAnimations.addPolishingWheels(widgets, 41, 63);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.ghasto.create_so.compat.rei;

public class ModReiCompat {
}
15 changes: 0 additions & 15 deletions src/main/java/com/ghasto/create_so/mixin/BeltInventoryAccess.java

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/create_so.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"package": "com.ghasto.create_so.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"BeltInventoryAccess",
"SandpaperItemMixin"
],
"client": [
Expand Down

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
],
"fabric-datagen": [
"com.ghasto.create_so.CreateSandpaperOverhaul"
],
"emi": [
"com.ghasto.create_so.compat.emi.ModEMICompat"
]
},
"mixins": [
Expand Down

0 comments on commit d1eb323

Please sign in to comment.