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

Add JEI support for end portal conversion and beacon conversion 为末地门转化与信标转化添加JEI支持 #1360

Merged
merged 11 commits into from
Dec 19, 2024
7 changes: 7 additions & 0 deletions src/generated/resources/assets/anvilcraft/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@
"entity.anvilcraft.floating_block": "ʞɔoןᗺ buıʇɐoןℲ",
"entity.minecraft.villager.anvilcraft.jeweler": "ɹǝןǝʍǝſ",
"gui.anvilcraft.category.average_output": "%s :ǝbɐɹǝʌⱯ",
"gui.anvilcraft.category.beacon_conversion": "uoısɹǝʌuoƆ uoɔɐǝᗺ",
"gui.anvilcraft.category.beacon_conversion.activate": "uoɔɐǝq ǝʇɐʌıʇɔɐ oʇ ɯǝʇı sıɥʇ ǝs∩",
"gui.anvilcraft.category.beacon_conversion.beacon_base": "ǝsɐq uoɔɐǝq sɐ ʞɔoןq sıɥʇ ǝs∩",
"gui.anvilcraft.category.block_compress": "ssǝɹdɯoƆ ʞɔoןᗺ",
"gui.anvilcraft.category.block_crush": "ɥsnɹƆ ʞɔoןᗺ",
"gui.anvilcraft.category.boiling": "buıןıoᗺ",
Expand All @@ -284,6 +287,8 @@
"gui.anvilcraft.category.chance": "%s%% :ǝɔuɐɥƆ",
"gui.anvilcraft.category.concrete": "ǝʇǝɹɔuoƆ",
"gui.anvilcraft.category.cooking": "buıʞooƆ",
"gui.anvilcraft.category.end_portal_conversion": "ןɐʇɹoԀ puƎ oʇuI sןןɐℲ ʞɔoןᗺ",
"gui.anvilcraft.category.end_portal_conversion.fall_through": "ןɐʇɹod puǝ ɥbnoɹɥʇ ןןɐɟ uǝɥʍ pǝʇɹǝʌuoƆ",
"gui.anvilcraft.category.item_compress": "ssǝɹdɯoƆ ɯǝʇI",
"gui.anvilcraft.category.item_crush": "ɥsnɹƆ ɯǝʇI",
"gui.anvilcraft.category.item_inject": "ʇɔǝظuI ɯǝʇI",
Expand Down Expand Up @@ -428,6 +433,7 @@
"itemGroup.anvilcraft.tools": "sǝıʇıןıʇ∩ :ʇɟɐɹƆןıʌuⱯ",
"jei.anvilcraft.info.capacitor": "˙ʇı uıɐʇqo oʇ ɹǝbɹɐɥɔ ǝɥʇ uı ɹoʇıɔɐdɐɔ ʎʇdɯǝ ǝɥʇ ǝbɹɐɥɔ uɐɔ noʎ",
"jei.anvilcraft.info.craw_claw": "˙ɹǝʇɐʍ ǝɥʇ uı pǝɔɐןd sdɐɹʇ qɐɹɔ ɯoɹɟ sıɥʇ uıɐʇqo uɐɔ noʎ",
"jei.anvilcraft.info.end_dust": "˙ןɐʇɹod puǝ ɥbnoɹɥʇ ןןɐɟ uǝɥʍ ʇsnᗡ puƎ oʇuı pǝʇɹǝʌuoɔ ǝq ןןıʍ 'bbƎ uobɐɹᗡ puɐ sןıʌuɐ ɹoɟ ʇdǝɔxǝ 'ʞɔoןq buıןןɐɟ ʎuⱯ",
"jei.anvilcraft.info.geode_1": "˙buısn uǝɥʍ ʎqɹɐǝu sǝpoǝ⅁ ʇsʎɥʇǝɯⱯ spuıℲ",
"jei.anvilcraft.info.geode_2": "˙sʞɔoןq ʇsʎɥʇǝɯⱯ buıppnᗺ ʎq pǝddoɹᗡ",
"jei.anvilcraft.info.geode_3": "ʇsǝɥƆ snuoᗺ ǝɥʇ uı ʇı puıɟ osןɐ uɐɔ noʎ",
Expand Down Expand Up @@ -577,6 +583,7 @@
"tooltip.anvilcraft.item.cut_heavy_iron_slab": "ɟooɹd uoısoןdxƎ",
"tooltip.anvilcraft.item.cut_heavy_iron_stairs": "ɟooɹd uoısoןdxƎ",
"tooltip.anvilcraft.item.cut_royal_steel_block": "ɟooɹd uoısoןdxƎ",
"tooltip.anvilcraft.item.cut_royal_steel_pillar": "ɟooɹd uoısoןdxƎ",
"tooltip.anvilcraft.item.cut_royal_steel_slab": "ɟooɹd uoısoןdxƎ",
"tooltip.anvilcraft.item.cut_royal_steel_stairs": "ɟooɹd uoısoןdxƎ",
"tooltip.anvilcraft.item.ember_anvil": "ɟooɹd ɹǝɥʇıM",
Expand Down
7 changes: 7 additions & 0 deletions src/generated/resources/assets/anvilcraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@
"entity.anvilcraft.floating_block": "Floating Block",
"entity.minecraft.villager.anvilcraft.jeweler": "Jeweler",
"gui.anvilcraft.category.average_output": "Average: %s",
"gui.anvilcraft.category.beacon_conversion": "Beacon Conversion",
"gui.anvilcraft.category.beacon_conversion.activate": "Use this item to activate beacon",
"gui.anvilcraft.category.beacon_conversion.beacon_base": "Use this block as beacon base",
"gui.anvilcraft.category.block_compress": "Block Compress",
"gui.anvilcraft.category.block_crush": "Block Crush",
"gui.anvilcraft.category.boiling": "Boiling",
Expand All @@ -284,6 +287,8 @@
"gui.anvilcraft.category.chance": "Chance: %s%%",
"gui.anvilcraft.category.concrete": "Concrete",
"gui.anvilcraft.category.cooking": "Cooking",
"gui.anvilcraft.category.end_portal_conversion": "Block Falls Into End Portal",
"gui.anvilcraft.category.end_portal_conversion.fall_through": "Converted when fall through end portal",
"gui.anvilcraft.category.item_compress": "Item Compress",
"gui.anvilcraft.category.item_crush": "Item Crush",
"gui.anvilcraft.category.item_inject": "Item Inject",
Expand Down Expand Up @@ -428,6 +433,7 @@
"itemGroup.anvilcraft.tools": "AnvilCraft: Utilities",
"jei.anvilcraft.info.capacitor": "You can charge the empty capacitor in the charger to obtain it.",
"jei.anvilcraft.info.craw_claw": "You can obtain this from crab traps placed in the water.",
"jei.anvilcraft.info.end_dust": "Any falling block, except for anvils and Dragon Egg, will be converted into End Dust when fall through end portal.",
"jei.anvilcraft.info.geode_1": "Finds Amethyst Geodes nearby when using.",
"jei.anvilcraft.info.geode_2": "Dropped by Budding Amethyst blocks.",
"jei.anvilcraft.info.geode_3": "You can also find it in the Bonus Chest",
Expand Down Expand Up @@ -577,6 +583,7 @@
"tooltip.anvilcraft.item.cut_heavy_iron_slab": "Explosion proof",
"tooltip.anvilcraft.item.cut_heavy_iron_stairs": "Explosion proof",
"tooltip.anvilcraft.item.cut_royal_steel_block": "Explosion proof",
"tooltip.anvilcraft.item.cut_royal_steel_pillar": "Explosion proof",
"tooltip.anvilcraft.item.cut_royal_steel_slab": "Explosion proof",
"tooltip.anvilcraft.item.cut_royal_steel_stairs": "Explosion proof",
"tooltip.anvilcraft.item.ember_anvil": "Wither proof",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class ItemTooltipManager {
map.put(ModBlocks.ROYAL_STEEL_BLOCK.asItem(), "Explosion proof");
map.put(ModBlocks.SMOOTH_ROYAL_STEEL_BLOCK.asItem(), "Explosion proof");
map.put(ModBlocks.CUT_ROYAL_STEEL_BLOCK.asItem(), "Explosion proof");
map.put(ModBlocks.CUT_ROYAL_STEEL_PILLAR.asItem(), "Explosion proof");
map.put(ModBlocks.CUT_ROYAL_STEEL_STAIRS.asItem(), "Explosion proof");
map.put(ModBlocks.CUT_ROYAL_STEEL_SLAB.asItem(), "Explosion proof");
map.put(ModBlocks.TEMPERING_GLASS.asItem(), "Explosion proof, No tools required on collect");
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/dev/dubhe/anvilcraft/data/lang/JeiLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ public static void init(RegistrateLangProvider provider) {

provider.add("gui.anvilcraft.category.jewel_crafting", "Jewel Crafting");

provider.add("gui.anvilcraft.category.end_portal_conversion", "Block Falls Into End Portal");
provider.add("gui.anvilcraft.category.end_portal_conversion.fall_through", "Converted when fall through end portal");

provider.add("gui.anvilcraft.category.beacon_conversion", "Beacon Conversion");
provider.add("gui.anvilcraft.category.beacon_conversion.activate", "Use this item to activate beacon");
provider.add("gui.anvilcraft.category.beacon_conversion.beacon_base", "Use this block as beacon base");

provider.add("jei.anvilcraft.info.geode_1", "Finds Amethyst Geodes nearby when using.");
provider.add("jei.anvilcraft.info.geode_2", "Dropped by Budding Amethyst blocks.");
provider.add("jei.anvilcraft.info.geode_3", "You can also find it in the Bonus Chest");
Expand All @@ -59,5 +66,8 @@ public static void init(RegistrateLangProvider provider) {
provider.add("jei.anvilcraft.info.craw_claw", "You can obtain this from crab traps placed in the water.");

provider.add("jei.anvilcraft.info.capacitor", "You can charge the empty capacitor in the charger to obtain it.");

provider.add("jei.anvilcraft.info.end_dust", "Any falling block, except for anvils and Dragon Egg, will be " +
"converted into End Dust when fall through end portal.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import dev.dubhe.anvilcraft.client.gui.screen.JewelCraftingScreen;
import dev.dubhe.anvilcraft.init.ModBlocks;
import dev.dubhe.anvilcraft.init.ModItems;
import dev.dubhe.anvilcraft.integration.jei.category.BeaconConversionCategory;
import dev.dubhe.anvilcraft.integration.jei.category.EndPortalConversionCategory;
import dev.dubhe.anvilcraft.integration.jei.category.JewelCraftingCategory;
import dev.dubhe.anvilcraft.integration.jei.category.anvil.BlockCompressCategory;
import dev.dubhe.anvilcraft.integration.jei.category.anvil.BlockCrushCategory;
Expand All @@ -21,8 +23,10 @@
import dev.dubhe.anvilcraft.integration.jei.category.anvil.SuperHeatingCategory;
import dev.dubhe.anvilcraft.integration.jei.category.anvil.TimeWarpCategory;
import dev.dubhe.anvilcraft.integration.jei.category.multiblock.MultiBlockCraftingCategory;
import dev.dubhe.anvilcraft.integration.jei.recipe.BeaconConversionRecipe;
import dev.dubhe.anvilcraft.integration.jei.recipe.CementStainingRecipe;
import dev.dubhe.anvilcraft.integration.jei.recipe.ColoredConcreteRecipe;
import dev.dubhe.anvilcraft.integration.jei.recipe.EndPortalConversionRecipe;
import dev.dubhe.anvilcraft.integration.jei.recipe.MeshRecipeGroup;
import dev.dubhe.anvilcraft.recipe.JewelCraftingRecipe;
import dev.dubhe.anvilcraft.recipe.anvil.BlockCompressRecipe;
Expand Down Expand Up @@ -69,6 +73,10 @@ public class AnvilCraftJeiPlugin implements IModPlugin {
createRecipeType("cement_staining", CementStainingRecipe.class);
public static final RecipeType<ColoredConcreteRecipe> COLORED_CONCRETE =
createRecipeType("colored_concrete", ColoredConcreteRecipe.class);
public static final RecipeType<EndPortalConversionRecipe> END_PORTAL_CONVERSION =
createRecipeType("end_portal_conversion", EndPortalConversionRecipe.class);
public static final RecipeType<BeaconConversionRecipe> BEACON_CONVERSION =
createRecipeType("beacon_conversion", BeaconConversionRecipe.class);

public static final RecipeType<RecipeHolder<BlockCompressRecipe>> BLOCK_COMPRESS =
createRecipeHolderType("block_compress");
Expand Down Expand Up @@ -114,6 +122,8 @@ public void registerRecipes(IRecipeRegistration registration) {
TimeWarpCategory.registerRecipes(registration);
MultiBlockCraftingCategory.registerRecipes(registration);
JewelCraftingCategory.registerRecipes(registration);
EndPortalConversionCategory.registerRecipes(registration);
BeaconConversionCategory.registerRecipes(registration);

registration.addItemStackInfo(
new ItemStack(ModItems.GEODE.get()),
Expand All @@ -131,6 +141,9 @@ public void registerRecipes(IRecipeRegistration registration) {
registration.addItemStackInfo(
new ItemStack(ModItems.CAPACITOR.get()),
Component.translatable("jei.anvilcraft.info.capacitor"));
registration.addItemStackInfo(
ModBlocks.END_DUST.asStack(),
Component.translatable("jei.anvilcraft.info.end_dust"));
}

@Override
Expand All @@ -152,6 +165,8 @@ public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
TimeWarpCategory.registerRecipeCatalysts(registration);
MultiBlockCraftingCategory.registerRecipeCatalysts(registration);
JewelCraftingCategory.registerRecipeCatalysts(registration);
EndPortalConversionCategory.registerRecipeCatalysts(registration);
BeaconConversionCategory.registerRecipeCatalysts(registration);

registration.addRecipeCatalyst(new ItemStack(ModBlocks.BATCH_CRAFTER), RecipeTypes.CRAFTING);

Expand Down Expand Up @@ -186,6 +201,8 @@ public void registerCategories(IRecipeCategoryRegistration registration) {
registration.addRecipeCategories(new TimeWarpCategory(guiHelper));
registration.addRecipeCategories(new MultiBlockCraftingCategory(guiHelper));
registration.addRecipeCategories(new JewelCraftingCategory(guiHelper));
registration.addRecipeCategories(new EndPortalConversionCategory(guiHelper));
registration.addRecipeCategories(new BeaconConversionCategory(guiHelper));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
package dev.dubhe.anvilcraft.integration.jei.category;

import dev.dubhe.anvilcraft.init.ModBlocks;
import dev.dubhe.anvilcraft.init.ModItems;
import dev.dubhe.anvilcraft.integration.jei.AnvilCraftJeiPlugin;
import dev.dubhe.anvilcraft.integration.jei.drawable.DrawableBlockStateIcon;
import dev.dubhe.anvilcraft.integration.jei.recipe.BeaconConversionRecipe;
import dev.dubhe.anvilcraft.integration.jei.util.JeiRecipeUtil;
import dev.dubhe.anvilcraft.integration.jei.util.TextureConstants;
import dev.dubhe.anvilcraft.util.LevelLike;
import dev.dubhe.anvilcraft.util.RenderHelper;
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.builder.IRecipeSlotBuilder;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.category.IRecipeCategory;
import mezz.jei.api.registration.IRecipeCatalystRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
import net.minecraft.ChatFormatting;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.block.Blocks;
import net.neoforged.neoforge.common.util.Lazy;
import org.jetbrains.annotations.Nullable;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.HashMap;
import java.util.Map;

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class BeaconConversionCategory implements IRecipeCategory<BeaconConversionRecipe> {
public static final int WIDTH = 162;
public static final int HEIGHT = 128;

private final Lazy<IDrawable> background;
private final IDrawable slot;
private final IDrawable progressArrow;
private final Component title;
private final Component activateTooltip;
private final Component beaconBaseTooltip;
private final IDrawable arrowIn;

private final Map<BeaconConversionRecipe, LevelLike> cache = new HashMap<>();

public BeaconConversionCategory(IGuiHelper helper) {
background = Lazy.of(() -> helper.createBlankDrawable(WIDTH, HEIGHT));
slot = helper.getSlotDrawable();
title = Component.translatable("gui.anvilcraft.category.beacon_conversion");
activateTooltip = Component.translatable("gui.anvilcraft.category.beacon_conversion.activate")
.withStyle(ChatFormatting.GOLD);
beaconBaseTooltip = Component.translatable("gui.anvilcraft.category.beacon_conversion.beacon_base")
.withStyle(ChatFormatting.GOLD);
progressArrow = helper.drawableBuilder(TextureConstants.PROGRESS, 0, 0, 24, 16)
.setTextureSize(24, 16)
.build();
arrowIn = helper.createDrawable(TextureConstants.ANVIL_CRAFT_SPRITES, 0, 31, 16, 8);
}

@Override
public RecipeType<BeaconConversionRecipe> getRecipeType() {
return AnvilCraftJeiPlugin.BEACON_CONVERSION;
}

@Override
public Component getTitle() {
return title;
}

@Override
public IDrawable getBackground() {
return background.get();
}

@Override
public @Nullable IDrawable getIcon() {
return new DrawableBlockStateIcon(
Blocks.BEACON.defaultBlockState(),
ModBlocks.CURSED_GOLD_BLOCK.getDefaultState()
);
}

@Override
public void setRecipe(
IRecipeLayoutBuilder builder, BeaconConversionRecipe recipe, IFocusGroup focuses) {
builder.addSlot(RecipeIngredientRole.INPUT, 48, 8)
.addItemStack(ModItems.CURSED_GOLD_INGOT.asStack())
.addRichTooltipCallback((recipeSlotView, tooltip) ->
tooltip.add(activateTooltip));
builder.addSlot(RecipeIngredientRole.CATALYST, 10, 110)
.addItemStack(ModBlocks.CURSED_GOLD_BLOCK.asStack(recipe.cursedGoldBlockCount))
.addRichTooltipCallback((recipeSlotView, tooltip) ->
tooltip.add(beaconBaseTooltip));
builder.addSlot(RecipeIngredientRole.INPUT, 10, 92)
.addItemStack(Blocks.BEACON.asItem().getDefaultInstance());
IRecipeSlotBuilder slot = builder.addSlot(RecipeIngredientRole.OUTPUT, 130, 96)
.addItemStack(ModBlocks.CORRUPTED_BEACON.asStack());
JeiRecipeUtil.addTooltips(slot, recipe.corruptedBeaconOutput.getAmount());
if (recipe.chance < 1.0f) {
slot = builder.addSlot(RecipeIngredientRole.OUTPUT, 112, 96)
.addItemStack(Blocks.BEACON.asItem().getDefaultInstance());
JeiRecipeUtil.addTooltips(slot, recipe.beaconOutput.getAmount());
}
}

@Override
public void draw(
BeaconConversionRecipe recipe,
IRecipeSlotsView recipeSlotsView,
GuiGraphics guiGraphics,
double mouseX,
double mouseY) {
LevelLike level = cache.get(recipe);
if (level == null) {
LevelLike beaconBase = new LevelLike(Minecraft.getInstance().level);
int layers = recipe.cursedGoldBlockLayers;
for (int i = 0; i < layers; i++) {
for (int j = i; j <= 2 * layers - i; j++) {
for (int k = i; k <= 2 * layers - i; k++) {
beaconBase.setBlockState(new BlockPos(j, i, k), ModBlocks.CURSED_GOLD_BLOCK.getDefaultState());
}
}
}
beaconBase.setBlockState(new BlockPos(layers, layers, layers), Blocks.BEACON.defaultBlockState());
cache.put(recipe, beaconBase);
level = beaconBase;
}

RenderHelper.renderLevelLike(level, guiGraphics, 90, 50, 90);

slot.draw(guiGraphics, 47, 7);
slot.draw(guiGraphics, 9, 109);
slot.draw(guiGraphics, 9, 91);
if (recipe.chance < 1.0f) slot.draw(guiGraphics, 111, 95);
slot.draw(guiGraphics, 129, 95);

arrowIn.draw(guiGraphics, 66, 14);
progressArrow.draw(guiGraphics, 60, 96);
}

public static void registerRecipes(IRecipeRegistration registration) {
registration.addRecipes(
AnvilCraftJeiPlugin.BEACON_CONVERSION,
BeaconConversionRecipe.getAllRecipes());
}

public static void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
registration.addRecipeCatalyst(ModBlocks.CURSED_GOLD_BLOCK.asStack(), AnvilCraftJeiPlugin.BEACON_CONVERSION);
}
}
Loading
Loading