Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item list things and forge!!!!!! #948

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ dependencies {

// REI
modCompileOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}"
modCompileOnly "me.shedaniel:RoughlyEnoughItems-api:${project.rei_version}"
//modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}"

// EMI
Expand Down Expand Up @@ -286,4 +287,4 @@ publishing {
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ hm_api_version=1.0.1+1.21.1
## Mod Menu (https://modrinth.com/mod/modmenu/versions)
mod_menu_version = 11.0.0-beta.1
## REI (https://modrinth.com/mod/rei/versions?l=fabric)
rei_version = 13.0.666
rei_version = 16.0.754
## EMI (https://modrinth.com/mod/emi/versions)
emi_version = 1.1.10+1.21
## JEI (https://modrinth.com/mod/jei/versions)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,70 @@
package de.hysky.skyblocker.compatibility.emi;

import de.hysky.skyblocker.skyblock.itemlist.SkyblockCraftingRecipe;
import dev.emi.emi.api.recipe.EmiCraftingRecipe;
import de.hysky.skyblocker.skyblock.itemlist.recipes.SkyblockRecipe;
import dev.emi.emi.api.recipe.EmiRecipe;
import dev.emi.emi.api.recipe.EmiRecipeCategory;
import dev.emi.emi.api.render.EmiTexture;
import dev.emi.emi.api.stack.EmiIngredient;
import dev.emi.emi.api.stack.EmiStack;
import dev.emi.emi.api.widget.WidgetHolder;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.ScreenPos;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;

public class SkyblockEmiRecipe extends EmiCraftingRecipe {
private final String craftText;
import java.util.List;

public SkyblockEmiRecipe(SkyblockCraftingRecipe recipe) {
super(recipe.getGrid().stream().map(EmiStack::of).map(EmiIngredient.class::cast).toList(), EmiStack.of(recipe.getResult()), recipe.getId());
this.craftText = recipe.getCraftText();
public class SkyblockEmiRecipe implements EmiRecipe {
private final Text craftText;
private final SkyblockRecipe recipe;

public SkyblockEmiRecipe(SkyblockRecipe recipe) {
this.craftText = recipe.getExtraText();
this.recipe = recipe;
}

@Override
public EmiRecipeCategory getCategory() {
return SkyblockerEMIPlugin.SKYBLOCK;
return SkyblockerEMIPlugin.IDENTIFIER_CATEGORY_MAP.get(recipe.getCategoryIdentifier());
}

@Override
public @Nullable Identifier getId() {
return recipe.getRecipeIdentifier();
}

@Override
public List<EmiIngredient> getInputs() {
return recipe.getInputs().stream().map(EmiStack::of).map(EmiIngredient.class::cast).toList();
}

@Override
public List<EmiStack> getOutputs() {
return recipe.getOutputs().stream().map(EmiStack::of).toList();
}

@Override
public int getDisplayWidth() {
return 118;
}

@Override
public int getDisplayHeight() {
return super.getDisplayHeight() + (craftText.isEmpty() ? 0 : 10);
return 54 + (craftText.getString().isEmpty() ? 0 : 10);
}

@Override
public void addWidgets(WidgetHolder widgets) {
super.addWidgets(widgets);
widgets.addText(Text.of(craftText), 59 - MinecraftClient.getInstance().textRenderer.getWidth(craftText) / 2, 55, 0xFFFFFF, true);
ScreenPos arrowLocation = recipe.getArrowLocation(getDisplayWidth(), getDisplayHeight());
if (arrowLocation != null) widgets.addTexture(EmiTexture.EMPTY_ARROW, arrowLocation.x(), arrowLocation.y());
widgets.addText(craftText, 59 - MinecraftClient.getInstance().textRenderer.getWidth(craftText) / 2, 55, 0xFFFFFF, true);
for (SkyblockRecipe.RecipeSlot inputSlot : recipe.getInputSlots(getDisplayWidth(), getDisplayHeight())) {
widgets.addSlot(EmiStack.of(inputSlot.stack()), inputSlot.x(), inputSlot.y());
}
for (SkyblockRecipe.RecipeSlot outputSlot : recipe.getOutputSlots(getDisplayWidth(), getDisplayHeight())) {
widgets.addSlot(EmiStack.of(outputSlot.stack()), outputSlot.x(), outputSlot.y()).recipeContext(this);
}
widgets.addDrawable(0, 0, getDisplayWidth(), getDisplayHeight(), (draw, mouseX, mouseY, delta) -> recipe.render(draw, getDisplayWidth(), getDisplayHeight(), mouseX, mouseY));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.skyblock.itemlist.ItemRepository;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.skyblock.itemlist.recipes.SkyblockCraftingRecipe;
import de.hysky.skyblocker.skyblock.itemlist.recipes.SkyblockForgeRecipe;
import dev.emi.emi.api.EmiPlugin;
import dev.emi.emi.api.EmiRegistry;
import dev.emi.emi.api.recipe.EmiRecipeCategory;
Expand All @@ -12,22 +13,32 @@
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;

import java.util.Map;

/**
* EMI integration
*/
public class SkyblockerEMIPlugin implements EmiPlugin {
public static final Identifier SIMPLIFIED_TEXTURES = Identifier.of("emi", "textures/gui/widgets.png");
// TODO: Custom simplified texture for Skyblock
public static final EmiRecipeCategory SKYBLOCK = new EmiRecipeCategory(Identifier.of(SkyblockerMod.NAMESPACE, "skyblock"), EmiStack.of(ItemUtils.getSkyblockerStack()), new EmiTexture(SIMPLIFIED_TEXTURES, 240, 240, 16, 16));
public static final Identifier SIMPLIFIED_TEXTURES = Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/emi_icons.png");

public static final EmiRecipeCategory SKYBLOCK_CRAFTING = new EmiRecipeCategory(SkyblockCraftingRecipe.IDENTIFIER, EmiStack.of(Items.CRAFTING_TABLE), new EmiTexture(SIMPLIFIED_TEXTURES, 0, 0, 16, 16));
public static final EmiRecipeCategory SKYBLOCK_FORGE = new EmiRecipeCategory(SkyblockForgeRecipe.IDENTIFIER, EmiStack.of(Items.LAVA_BUCKET), new EmiTexture(SIMPLIFIED_TEXTURES, 16, 0, 16, 16));

protected static final Map<Identifier, EmiRecipeCategory> IDENTIFIER_CATEGORY_MAP = Map.of(
SkyblockCraftingRecipe.IDENTIFIER, SKYBLOCK_CRAFTING,
SkyblockForgeRecipe.IDENTIFIER, SKYBLOCK_FORGE
);

@Override
public void register(EmiRegistry registry) {
ItemRepository.getItemsStream().map(EmiStack::of).forEach(emiStack -> {
registry.addEmiStack(emiStack);
registry.setDefaultComparison(emiStack, Comparison.compareComponents());
registry.setDefaultComparison(emiStack, Comparison.compareData(emiStack1 -> emiStack1.getItemStack().getSkyblockId()));
});
registry.addCategory(SKYBLOCK);
registry.addWorkstation(SKYBLOCK, EmiStack.of(Items.CRAFTING_TABLE));
registry.addCategory(SKYBLOCK_CRAFTING);
registry.addCategory(SKYBLOCK_FORGE);
registry.addWorkstation(SKYBLOCK_CRAFTING, EmiStack.of(Items.CRAFTING_TABLE));
registry.addWorkstation(SKYBLOCK_CRAFTING, EmiStack.of(Items.LAVA_BUCKET));
ItemRepository.getRecipesStream().map(SkyblockEmiRecipe::new).forEach(registry::addRecipe);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class SkyblockCraftingRecipeCategory extends CraftingRecipeCategory {
@SuppressWarnings({"unchecked", "RedundantCast", "rawtypes"})
private static final RecipeType<RecipeEntry<CraftingRecipe>> SKYBLOCK_RECIPE = new RecipeType<>(Identifier.of(SkyblockerMod.NAMESPACE, "skyblock"), (Class<? extends RecipeEntry<CraftingRecipe>>) (Class) RecipeEntry.class);
private final Text title = Text.translatable("emi.category.skyblocker.skyblock");
private final Text title = Text.translatable("emi.category.skyblocker.skyblock_crafting");
private final IDrawable icon;

public SkyblockCraftingRecipeCategory(IGuiHelper guiHelper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.skyblock.itemlist.ItemRepository;
import de.hysky.skyblocker.skyblock.itemlist.recipes.SkyblockCraftingRecipe;
import de.hysky.skyblocker.utils.datafixer.ItemStackComponentizationFixer;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
Expand Down Expand Up @@ -48,8 +49,8 @@ public void registerCategories(@NotNull IRecipeCategoryRegistration registration
@Override
public void registerRecipes(@NotNull IRecipeRegistration registration) {
registration.getIngredientManager().addIngredientsAtRuntime(VanillaTypes.ITEM_STACK, ItemRepository.getItems());
registration.addRecipes(skyblockCraftingRecipeCategory.getRecipeType(), ItemRepository.getRecipesStream().map(recipe ->
new RecipeEntry<CraftingRecipe>(recipe.getId(), new ShapedRecipe("", CraftingRecipeCategory.MISC, RawShapedRecipe.create(Map.of(
registration.addRecipes(skyblockCraftingRecipeCategory.getRecipeType(), ItemRepository.getRecipesStream().filter(skyblockRecipe -> skyblockRecipe instanceof SkyblockCraftingRecipe).map(SkyblockCraftingRecipe.class::cast).map(recipe ->
new RecipeEntry<CraftingRecipe>(recipe.getRecipeIdentifier(), new ShapedRecipe("", CraftingRecipeCategory.MISC, RawShapedRecipe.create(Map.of(
'a', Ingredient.ofStacks(recipe.getGrid().get(0)),
'b', Ingredient.ofStacks(recipe.getGrid().get(1)),
'c', Ingredient.ofStacks(recipe.getGrid().get(2)),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading