Skip to content

Commit

Permalink
re-add jei
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Jun 23, 2024
1 parent a26c536 commit b7b1565
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 42 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ type="test"
classification="test"

#jei setting
include_jei=false
jei_mc_version=1.20.6
jei_version=18.0.0.62
include_jei=true
jei_mc_version=1.21
jei_version=19.0.0.9

#guideapi setting
include_guideapi=false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.teamlapen.vampirism.client.gui.screens;

import de.teamlapen.lib.lib.util.MultilineTooltip;
import de.teamlapen.vampirism.REFERENCE;
import de.teamlapen.vampirism.api.entity.player.skills.ISkill;
import de.teamlapen.vampirism.api.util.VResourceLocation;
Expand All @@ -8,7 +9,9 @@
import de.teamlapen.vampirism.inventory.AlchemicalCauldronMenu;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.navigation.ScreenRectangle;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.tooltip.BelowOrAboveWidgetTooltipPositioner;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -22,10 +25,10 @@


public class AlchemicalCauldronScreen extends AbstractContainerScreen<AlchemicalCauldronMenu> {
private static final ResourceLocation BACKGROUND = VResourceLocation.mod("textures/gui/container/alchemical_cauldron.png");
private static final ResourceLocation LIT_PROGRESS_SPRITE = VResourceLocation.mod("container/alchemical_cauldron/lit_progress");
private static final ResourceLocation BURN_PROGRESS_SPRITE = VResourceLocation.mod("container/alchemical_cauldron/burn_progress");
private static final ResourceLocation BUBBLES_PROGRESS_SPRITE = VResourceLocation.mod("container/alchemical_cauldron/bubbles_progress");
public static final ResourceLocation BACKGROUND = VResourceLocation.mod("textures/gui/container/alchemical_cauldron.png");
public static final ResourceLocation LIT_PROGRESS_SPRITE = VResourceLocation.mod("container/alchemical_cauldron/lit_progress");
public static final ResourceLocation BURN_PROGRESS_SPRITE = VResourceLocation.mod("container/alchemical_cauldron/burn_progress");
public static final ResourceLocation BUBBLES_PROGRESS_SPRITE = VResourceLocation.mod("container/alchemical_cauldron/bubbles_progress");
private static final ResourceLocation ERROR_SPRITE = ResourceLocation.withDefaultNamespace("container/anvil/error");

public AlchemicalCauldronScreen(@NotNull AlchemicalCauldronMenu inventorySlotsIn, @NotNull Inventory inventoryPlayer, @NotNull Component name) {
Expand Down Expand Up @@ -73,7 +76,7 @@ protected void renderTooltip(GuiGraphics pGuiGraphics, int pX, int pY) {
List<ISkill<?>> missingSkills = holder.value().getRequiredSkills().stream().filter(s -> !HunterPlayer.get(this.minecraft.player).getSkillHandler().isSkillEnabled(s)).toList();
if (!missingSkills.isEmpty()) {
List<Component> components = Stream.concat(Stream.of(Component.translatable("gui.vampirism.alchemical_cauldron.missing_skills").withStyle(ChatFormatting.RED)), missingSkills.stream().map(skill -> Component.literal("p- ").append(skill.getName()).withStyle(ChatFormatting.RED))).collect(Collectors.toUnmodifiableList());
pGuiGraphics.renderComponentTooltip(this.font, components, pX, pY);
setTooltipForNextRenderPass(new MultilineTooltip(components),new BelowOrAboveWidgetTooltipPositioner(new ScreenRectangle(i +77, j +32, 28, 21)), false);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
public class PotionTableScreen extends AbstractContainerScreen<PotionTableMenu> {

private static final int[] BUBBLELENGTHS = new int[]{29, 24, 20, 16, 11, 6, 0};
private final ResourceLocation BACKGROUND = VResourceLocation.mod("textures/gui/container/potion_table.png");
private final ResourceLocation BACKGROUND_EXTENDED = VResourceLocation.mod("textures/gui/container/potion_table_extended.png");
private final ResourceLocation FUEL_SPRITE = VResourceLocation.mod("container/potion_table/fuel");
private final ResourceLocation PROGRESS_SPRITE = VResourceLocation.mod("container/potion_table/progress");
private final ResourceLocation BUBBLES_SPRITE = VResourceLocation.mod("container/potion_table/bubbles");
public static final ResourceLocation BACKGROUND = VResourceLocation.mod("textures/gui/container/potion_table.png");
private static final ResourceLocation BACKGROUND_EXTENDED = VResourceLocation.mod("textures/gui/container/potion_table_extended.png");
public static final ResourceLocation FUEL_SPRITE = VResourceLocation.mod("container/potion_table/fuel");
public static final ResourceLocation PROGRESS_SPRITE = VResourceLocation.mod("container/potion_table/progress");
public static final ResourceLocation BUBBLES_SPRITE = VResourceLocation.mod("container/potion_table/bubbles");


public PotionTableScreen(@NotNull PotionTableMenu screenContainer, @NotNull Inventory inv, @NotNull Component titleIn) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
package de.teamlapen.vampirism.client.gui.screens;

import de.teamlapen.lib.lib.util.MultilineTooltip;
import de.teamlapen.vampirism.REFERENCE;
import de.teamlapen.vampirism.api.entity.player.hunter.IHunterPlayer;
import de.teamlapen.vampirism.api.entity.player.skills.ISkill;
import de.teamlapen.vampirism.api.util.VResourceLocation;
import de.teamlapen.vampirism.inventory.WeaponTableMenu;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.navigation.ScreenRectangle;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.tooltip.BelowOrAboveWidgetTooltipPositioner;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Gui for the weapon table. Only draws the background and the lava status
*/
public class WeaponTableScreen extends AbstractContainerScreen<WeaponTableMenu> {

private static final ResourceLocation BACKGROUND = VResourceLocation.mod("textures/gui/container/weapon_table.png");
public static final ResourceLocation BACKGROUND = VResourceLocation.mod("textures/gui/container/weapon_table.png");
private static final ResourceLocation LAVA_SPRITE = VResourceLocation.mod("container/weapon_table/lava");
private static final ResourceLocation EMPTY_BUCKET_SPRITE = VResourceLocation.mod("container/weapon_table/empty_bucket");
private static final ResourceLocation MISSING_LAVA_SPRITE = VResourceLocation.mod("container/weapon_table/missing_lava");
private static final ResourceLocation ERROR_SPRITE = ResourceLocation.withDefaultNamespace("container/anvil/error");

public WeaponTableScreen(@NotNull WeaponTableMenu inventorySlotsIn, @NotNull Inventory inventoryPlayer, @NotNull Component name) {
super(inventorySlotsIn, inventoryPlayer, name);
Expand All @@ -38,12 +51,31 @@ protected void renderBg(@NotNull GuiGraphics graphics, float partialTicks, int m
int i = this.leftPos;
int j = (this.height - this.imageHeight) / 2;
graphics.blit(BACKGROUND, i, j, 0, 0, this.imageWidth, this.imageHeight);

graphics.blitSprite(EMPTY_BUCKET_SPRITE, i+154, j+71, 24, 28);
if (menu.hasLava()) {
graphics.blitSprite(LAVA_SPRITE, i+154, j+71, 24, 28);
}
if (menu.isMissingLava()) {
graphics.blitSprite(MISSING_LAVA_SPRITE, i+152, j+69, 28, 32);
}

List<ISkill<IHunterPlayer>> missingSkills = this.menu.missingSkills().orElse(List.of());
if (!missingSkills.isEmpty()) {
graphics.blitSprite(ERROR_SPRITE, i + 110, j + 43, 28, 21);
}
}

@Override
protected void renderTooltip(GuiGraphics pGuiGraphics, int pX, int pY) {
int i = (this.width - this.imageWidth) / 2;
int j = (this.height - this.imageHeight) / 2;
List<ISkill<IHunterPlayer>> missingSkills = this.menu.missingSkills().orElse(List.of());
if (pX > i + 110 && pX < i + 110 + 28 && pY > j + 43 && pY < j + 43 + 21 && !missingSkills.isEmpty()) {
List<Component> components = Stream.concat(Stream.of(Component.translatable("gui.vampirism.weapon_table.missing_skills").withStyle(ChatFormatting.RED)), missingSkills.stream().map(skill -> Component.literal("- ").append(skill.getName()).withStyle(ChatFormatting.RED))).collect(Collectors.toUnmodifiableList());
setTooltipForNextRenderPass(new MultilineTooltip(components),new BelowOrAboveWidgetTooltipPositioner(new ScreenRectangle(i +110, j +43, 28, 21)), false);
} else {
super.renderTooltip(pGuiGraphics, pX, pY);
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/de/teamlapen/vampirism/core/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public boolean isFoil(ItemStack stack) {
@Override
public void appendHoverText(@NotNull ItemStack stack, @Nullable TooltipContext context, @NotNull List<Component> texts, @NotNull TooltipFlag flag) {
texts.add(Component.translatable("item.vampirism.tech_crossbow_ammo_package.tooltip", Component.translatable(BASIC_TECH_CROSSBOW.get().getDescriptionId())).withStyle(ChatFormatting.GRAY));
texts.add(Component.empty());
texts.add(Component.translatable("item.vampirism.arrow_clip.right_click").withStyle(ChatFormatting.GRAY));
super.appendHoverText(stack, context, texts, flag);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
package de.teamlapen.vampirism.inventory;

import com.google.common.collect.Lists;
import de.teamlapen.lib.lib.inventory.BooleanDataSlot;
import de.teamlapen.vampirism.api.entity.player.hunter.IHunterPlayer;
import de.teamlapen.vampirism.api.entity.player.skills.ISkill;
import de.teamlapen.vampirism.api.items.IWeaponTableRecipe;
import de.teamlapen.vampirism.blocks.WeaponTableBlock;
import de.teamlapen.vampirism.core.ModBlocks;
import de.teamlapen.vampirism.core.ModMenus;
import de.teamlapen.vampirism.core.ModRecipes;
import de.teamlapen.vampirism.entity.player.hunter.HunterPlayer;
import de.teamlapen.vampirism.util.Helper;
import net.minecraft.client.RecipeBookCategories;
import net.minecraft.core.BlockPos;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
import net.minecraft.recipebook.ServerPlaceRecipe;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.StackedContents;
import net.minecraft.world.inventory.*;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -161,6 +157,13 @@ public boolean stillValid(@NotNull Player playerIn) {
return stillValid(this.worldPos, playerIn, ModBlocks.WEAPON_TABLE.get());
}

public Optional<List<ISkill<IHunterPlayer>>> missingSkills() {
return this.worldPos.evaluate((world, pos) -> {
Optional<RecipeHolder<IWeaponTableRecipe>> recipeFor = quickCheck.getRecipeFor(CraftingInput.of(this.craftMatrix.getWidth(), this.craftMatrix.getHeight(), this.craftMatrix.getItems()), world);
return recipeFor.stream().flatMap(s -> s.value().getRequiredSkills().stream()).filter(s -> !hunterPlayer.getSkillHandler().isSkillEnabled(s)).toList();
});
}

private void slotChangedCraftingGrid(@NotNull Level worldIn, Player playerIn, @NotNull HunterPlayer hunter, @NotNull CraftingInput craftMatrixIn, @NotNull ResultContainer craftResultIn) {
if (!worldIn.isClientSide && playerIn instanceof ServerPlayer serverPlayer) {
Optional<RecipeHolder<IWeaponTableRecipe>> optional = quickCheck.getRecipeFor(craftMatrixIn, worldIn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import de.teamlapen.lib.lib.util.UtilLib;
import de.teamlapen.lib.util.Color;
import de.teamlapen.vampirism.REFERENCE;
import de.teamlapen.vampirism.api.entity.player.skills.ISkill;
import de.teamlapen.vampirism.client.gui.screens.AlchemicalCauldronScreen;
import de.teamlapen.vampirism.core.ModBlocks;
import de.teamlapen.vampirism.recipes.AlchemicalCauldronRecipe;
import mezz.jei.api.constants.VanillaTypes;
Expand All @@ -29,7 +29,6 @@


public class AlchemicalCauldronRecipeCategory implements IRecipeCategory<RecipeHolder<AlchemicalCauldronRecipe>> {
private static final ResourceLocation BACKGROUND = VResourceLocation.mod("textures/gui/alchemical_cauldron.png");
private final @NotNull Component localizedName;
private final @NotNull IDrawable background;
private final @NotNull IDrawable icon;
Expand All @@ -41,17 +40,20 @@ public class AlchemicalCauldronRecipeCategory implements IRecipeCategory<RecipeH
AlchemicalCauldronRecipeCategory(@NotNull IGuiHelper guiHelper) {
this.localizedName = Component.translatable(ModBlocks.ALCHEMICAL_CAULDRON.get().getDescriptionId());
this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(ModBlocks.ALCHEMICAL_CAULDRON.get()));
this.background = guiHelper.drawableBuilder(BACKGROUND, 38, 10, 120, 70).addPadding(0, 33, 0, 0).build();
this.background = guiHelper.drawableBuilder(AlchemicalCauldronScreen.BACKGROUND, 38, 10, 120, 70).addPadding(0, 33, 0, 0).build();

IDrawableStatic flameDrawable = guiHelper.createDrawable(BACKGROUND, 176, 0, 14, 14);
IDrawableStatic flameDrawable = guiHelper.drawableBuilder(fixSprite(AlchemicalCauldronScreen.LIT_PROGRESS_SPRITE), 0, 0, 14, 14).setTextureSize(14, 14).build();
this.flame = guiHelper.createAnimatedDrawable(flameDrawable, 300, IDrawableAnimated.StartDirection.TOP, true);

IDrawableStatic arrowDrawable = guiHelper.createDrawable(BACKGROUND, 176, 14, 24, 17);
IDrawableStatic arrowDrawable = guiHelper.drawableBuilder(fixSprite(AlchemicalCauldronScreen.BURN_PROGRESS_SPRITE), 0, 0, 24, 16).setTextureSize(24, 16).build();
this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 200, IDrawableAnimated.StartDirection.LEFT, false);

IDrawableStatic bubblesDrawable = guiHelper.createDrawable(BACKGROUND, 176, 31, 12, 29);
IDrawableStatic bubblesDrawable = guiHelper.drawableBuilder(fixSprite(AlchemicalCauldronScreen.BUBBLES_PROGRESS_SPRITE), 0, 0, 12, 29).setTextureSize(12, 29).build();
this.bubbles = guiHelper.createAnimatedDrawable(bubblesDrawable, 200, IDrawableAnimated.StartDirection.BOTTOM, false);
}

private static ResourceLocation fixSprite(ResourceLocation spriteLoc) {
return spriteLoc.withPrefix("textures/gui/sprites/").withSuffix(".png");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.teamlapen.lib.lib.util.UtilLib;
import de.teamlapen.vampirism.REFERENCE;
import de.teamlapen.vampirism.api.entity.player.skills.ISkill;
import de.teamlapen.vampirism.api.util.VResourceLocation;
import de.teamlapen.vampirism.core.ModBlocks;
import de.teamlapen.vampirism.items.component.OilContent;
import de.teamlapen.vampirism.recipes.AlchemyTableRecipe;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.teamlapen.vampirism.modcompat.jei;

import de.teamlapen.vampirism.REFERENCE;
import de.teamlapen.vampirism.api.util.VResourceLocation;
import de.teamlapen.vampirism.core.ModBlocks;
import de.teamlapen.vampirism.entity.player.hunter.skills.HunterSkills;
import de.teamlapen.vampirism.items.BlessableItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.teamlapen.vampirism.modcompat.jei;

import de.teamlapen.lib.util.Color;
import de.teamlapen.vampirism.REFERENCE;
import de.teamlapen.vampirism.client.gui.screens.PotionTableScreen;
import de.teamlapen.vampirism.core.ModBlocks;
import de.teamlapen.vampirism.entity.player.hunter.skills.HunterSkills;
import mezz.jei.api.constants.VanillaTypes;
Expand All @@ -26,26 +26,33 @@

public class PotionTableRecipeCategory implements IRecipeCategory<JEIPotionMix> {

private static final ResourceLocation backgroundLocation = VResourceLocation.mod("textures/gui/container/potion_table.png");
private final @NotNull Component localizedName;
private final @NotNull IDrawable background;
private final @NotNull IDrawable icon;
private final @NotNull IDrawable slotDrawable;
private final @NotNull IDrawableAnimated arrow;
private final @NotNull IDrawableAnimated bubbles;
private final @NotNull IDrawableStatic blazeHeat;
private final @NotNull IDrawable arrow;
private final @NotNull IDrawable bubbles;
private final @NotNull IDrawable blazeHeat;


PotionTableRecipeCategory(@NotNull IGuiHelper guiHelper) {
this.localizedName = Component.translatable(ModBlocks.POTION_TABLE.get().getDescriptionId());
this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(ModBlocks.POTION_TABLE.get()));
this.background = guiHelper.drawableBuilder(backgroundLocation, 65, 6, 103, 73).addPadding(0, 33, 0, 25).build();
this.background = guiHelper.drawableBuilder(PotionTableScreen.BACKGROUND, 65, 6, 103, 73).addPadding(0, 33, 0, 25).build();
this.slotDrawable = guiHelper.getSlotDrawable();
ITickTimer bubblesTickTimer = new BrewingBubblesTickTimer(guiHelper);
this.bubbles = guiHelper.drawableBuilder(backgroundLocation, 185, 0, 12, 29).buildAnimated(bubblesTickTimer, IDrawableAnimated.StartDirection.BOTTOM);
this.blazeHeat = guiHelper.createDrawable(backgroundLocation, 176, 29, 18, 4);
this.arrow = guiHelper.drawableBuilder(backgroundLocation, 176, 0, 9, 28).buildAnimated(400, IDrawableAnimated.StartDirection.TOP, false);

var bubbles = guiHelper.drawableBuilder(fixSprite(PotionTableScreen.BUBBLES_SPRITE), 0, 0, 12, 29).setTextureSize(12, 29).build();
this.bubbles = guiHelper.createAnimatedDrawable(bubbles, 400, IDrawableAnimated.StartDirection.BOTTOM, false);

var blaze = guiHelper.drawableBuilder(fixSprite(PotionTableScreen.FUEL_SPRITE), 0, 0, 18, 4).setTextureSize(18,4).build();
this.blazeHeat = guiHelper.createAnimatedDrawable(blaze, 400, IDrawableAnimated.StartDirection.LEFT, false);

var progress =guiHelper.drawableBuilder(fixSprite(PotionTableScreen.PROGRESS_SPRITE), 0, 0, 9, 28).setTextureSize(9, 28).build();
this.arrow = guiHelper.createAnimatedDrawable(progress, 400, IDrawableAnimated.StartDirection.TOP, false);
}

private static ResourceLocation fixSprite(ResourceLocation spriteLoc) {
return spriteLoc.withPrefix("textures/gui/sprites/").withSuffix(".png");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import de.teamlapen.vampirism.api.entity.player.task.Task;
import de.teamlapen.vampirism.api.entity.player.task.TaskReward;
import de.teamlapen.vampirism.api.entity.player.task.TaskUnlocker;
import de.teamlapen.vampirism.api.util.VResourceLocation;
import de.teamlapen.vampirism.core.ModItems;
import de.teamlapen.vampirism.entity.player.tasks.reward.ItemReward;
import mezz.jei.api.constants.ModIds;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.builder.IRecipeSlotBuilder;
Expand Down Expand Up @@ -39,7 +41,7 @@ public class TaskRecipeCategory implements IRecipeCategory<Task> {
private final IGuiHelper guiHelper;

public TaskRecipeCategory(@NotNull IGuiHelper guiHelper) {
this.background = guiHelper.drawableBuilder(new ResourceLocation("jei", "textures/jei/gui/gui_vanilla.png"), 90, 168, 18, 18).addPadding(14, 90, 75, 75).build();
this.background = guiHelper.drawableBuilder(VResourceLocation.loc(ModIds.JEI_ID, "textures/jei/atlas/gui/slot.png"), 0, 0, 18, 18).setTextureSize(18,18).addPadding(14, 90, 75, 75).build();
this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(ModItems.VAMPIRE_FANG.get()));
this.guiHelper = guiHelper;
}
Expand Down
Loading

0 comments on commit b7b1565

Please sign in to comment.