From 8109538f3acce6c2edeb1e78bcb08e96c4396b32 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Wed, 14 May 2025 19:32:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0JEI=E7=9A=84=E8=83=8C?= =?UTF-8?q?=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compat/jei/GunPerksCategory.java | 29 +++++++++++++++--- .../textures/gui/jei_gun_perks.png | Bin 0 -> 916 bytes 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/assets/superbwarfare/textures/gui/jei_gun_perks.png diff --git a/src/main/java/com/atsuishio/superbwarfare/compat/jei/GunPerksCategory.java b/src/main/java/com/atsuishio/superbwarfare/compat/jei/GunPerksCategory.java index aeb8bb59a..720fa6ea7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/compat/jei/GunPerksCategory.java +++ b/src/main/java/com/atsuishio/superbwarfare/compat/jei/GunPerksCategory.java @@ -8,12 +8,16 @@ import com.atsuishio.superbwarfare.perk.Perk; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; 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 net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -21,17 +25,34 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; -// TODO 来个正常一点的背景 public class GunPerksCategory implements IRecipeCategory { + public static final ResourceLocation TEXTURE = Mod.loc("textures/gui/jei_gun_perks.png"); public static final RecipeType TYPE = RecipeType.create(Mod.MODID, "gun_perks", ItemStack.class); + private final IDrawable background; private final IDrawable icon; public GunPerksCategory(IGuiHelper helper) { + this.background = helper.drawableBuilder(TEXTURE, 0, 0, 144, 128) + .setTextureSize(144, 128) + .build(); this.icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(ModItems.AP_BULLET.get())); } + @Override + public void draw(ItemStack recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { + var name = recipe.getHoverName(); + guiGraphics.drawString(Minecraft.getInstance().font, name, + 80 - Minecraft.getInstance().font.width(name) / 2, 5, 5592405, false); + } + + @SuppressWarnings("removal") + @Override + public @Nullable IDrawable getBackground() { + return this.background; + } + @Override public @NotNull RecipeType getRecipeType() { return TYPE; @@ -49,7 +70,7 @@ public class GunPerksCategory implements IRecipeCategory { @Override public int getWidth() { - return 140; + return 144; } @Override @@ -69,11 +90,11 @@ public class GunPerksCategory implements IRecipeCategory { return (aIndex == bIndex) ? a.name.compareTo(b.name) : aIndex - bIndex; }); - builder.addSlot(RecipeIngredientRole.INPUT, 5, 0).addItemStack(stack); + builder.addSlot(RecipeIngredientRole.INPUT, 1, 1).addItemStack(stack); for (int i = 0; i < sortedPerks.size(); i++) { var perkItem = sortedPerks.get(i).getItem().get(); - builder.addSlot(RecipeIngredientRole.INPUT, 5 + (i % 7) * 18, 20 + i / 7 * 18).addItemStack(perkItem.getDefaultInstance()); + builder.addSlot(RecipeIngredientRole.INPUT, 1 + (i % 8) * 18, 21 + i / 8 * 18).addItemStack(perkItem.getDefaultInstance()); } } diff --git a/src/main/resources/assets/superbwarfare/textures/gui/jei_gun_perks.png b/src/main/resources/assets/superbwarfare/textures/gui/jei_gun_perks.png new file mode 100644 index 0000000000000000000000000000000000000000..a47d2f9660e059b92a7caee19fa364264ab08e41 GIT binary patch literal 916 zcmeAS@N?(olHy`uVBq!ia0vp^6M(pZgAGVNneafFfq}6l)7d$|)7e>}peR2rGbfdS zL1SX=L|c!;4iatmmx=vf#aAX!cp_l#n?*`}OS@b*1l;0UYc(V07rU?2BoT4i_RhLR_?G@!V??k0P9yJUb=?I!lU1bX-_BF-ghwxgr1m6_5QV zd8>s>_Q-IraB6+>qxRaj z>&+T=`d@mTt6RgulgliAJ=gahvtD__MD+P+Bye$Sit_Le-bG0rJSF``>d9PG@;+ zeCs3IA!R9`)yT#H4OUQKanaR#_XenDbIx(sMRTw8nG48W#O~~@!oqZrnpA5&p|?xQ z_B4Lza0B@e