添加JEI的背景
This commit is contained in:
parent
7ac153252d
commit
8109538f3a
2 changed files with 25 additions and 4 deletions
|
@ -8,12 +8,16 @@ import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import mezz.jei.api.constants.VanillaTypes;
|
import mezz.jei.api.constants.VanillaTypes;
|
||||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
|
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
|
||||||
import mezz.jei.api.gui.drawable.IDrawable;
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
|
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
|
||||||
import mezz.jei.api.helpers.IGuiHelper;
|
import mezz.jei.api.helpers.IGuiHelper;
|
||||||
import mezz.jei.api.recipe.IFocusGroup;
|
import mezz.jei.api.recipe.IFocusGroup;
|
||||||
import mezz.jei.api.recipe.RecipeIngredientRole;
|
import mezz.jei.api.recipe.RecipeIngredientRole;
|
||||||
import mezz.jei.api.recipe.RecipeType;
|
import mezz.jei.api.recipe.RecipeType;
|
||||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
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.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -21,17 +25,34 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
// TODO 来个正常一点的背景
|
|
||||||
public class GunPerksCategory implements IRecipeCategory<ItemStack> {
|
public class GunPerksCategory implements IRecipeCategory<ItemStack> {
|
||||||
|
|
||||||
|
public static final ResourceLocation TEXTURE = Mod.loc("textures/gui/jei_gun_perks.png");
|
||||||
public static final RecipeType<ItemStack> TYPE = RecipeType.create(Mod.MODID, "gun_perks", ItemStack.class);
|
public static final RecipeType<ItemStack> TYPE = RecipeType.create(Mod.MODID, "gun_perks", ItemStack.class);
|
||||||
|
|
||||||
|
private final IDrawable background;
|
||||||
private final IDrawable icon;
|
private final IDrawable icon;
|
||||||
|
|
||||||
public GunPerksCategory(IGuiHelper helper) {
|
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()));
|
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
|
@Override
|
||||||
public @NotNull RecipeType<ItemStack> getRecipeType() {
|
public @NotNull RecipeType<ItemStack> getRecipeType() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
|
@ -49,7 +70,7 @@ public class GunPerksCategory implements IRecipeCategory<ItemStack> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
return 140;
|
return 144;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,11 +90,11 @@ public class GunPerksCategory implements IRecipeCategory<ItemStack> {
|
||||||
return (aIndex == bIndex) ? a.name.compareTo(b.name) : aIndex - bIndex;
|
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++) {
|
for (int i = 0; i < sortedPerks.size(); i++) {
|
||||||
var perkItem = sortedPerks.get(i).getItem().get();
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 916 B |
Loading…
Add table
Reference in a new issue