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 000000000..a47d2f966 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/textures/gui/jei_gun_perks.png differ