diff --git a/src/main/java/de/teamlapen/vampirism/items/VampireSwordItem.java b/src/main/java/de/teamlapen/vampirism/items/VampireSwordItem.java index 7f5dbbc08..c12a35507 100644 --- a/src/main/java/de/teamlapen/vampirism/items/VampireSwordItem.java +++ b/src/main/java/de/teamlapen/vampirism/items/VampireSwordItem.java @@ -126,7 +126,7 @@ public ItemStack finishUsingItem(@NotNull ItemStack stack, @NotNull Level worldI if (!(entityLiving instanceof Player player)) return stack; VampirePlayer vampire = VampirePlayer.get(player); int amount = (vampire.getRefinementHandler().isRefinementEquipped(ModRefinements.BLOOD_CHARGE_SPEED) ? VampirismConfig.BALANCE.vrBloodChargeSpeedMod.get() : 2); - if (((Player) entityLiving).isCreative() || vampire.useBlood(amount, false)) { + if (player.isCreative() || vampire.useBlood(amount, false)) { this.charge(stack, amount * VReference.FOOD_TO_FLUID_BLOOD); } if (getChargePercentage(stack) == 1) { @@ -174,7 +174,7 @@ public boolean isFullyCharged(@NotNull ItemStack stack) { } @Override - public boolean onEntitySwing(ItemStack stack, LivingEntity entity) { + public boolean onEntitySwing(ItemStack stack, LivingEntity entity, InteractionHand hand) { return !Helper.isVampire(entity); } diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/AlchemicalCauldronRecipeCategory.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/AlchemicalCauldronRecipeCategory.java index f5efdbcd8..f970c3587 100644 --- a/src/main/java/de/teamlapen/vampirism/modcompat/jei/AlchemicalCauldronRecipeCategory.java +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/AlchemicalCauldronRecipeCategory.java @@ -53,12 +53,14 @@ public class AlchemicalCauldronRecipeCategory implements IRecipeCategory holder, @NotNull IRecipeSlotsView recipeSlotsView, @NotNull GuiGraphics graphics, double mouseX, double mouseY) { + this.background.draw(graphics); + graphics.pose().pushPose(); AlchemicalCauldronRecipe recipe = holder.value(); this.flame.draw(graphics, 19, 27); this.arrow.draw(graphics, 41, 25); @@ -79,13 +81,17 @@ public void draw(@NotNull RecipeHolder holder, @NotNul } y += UtilLib.renderMultiLine(minecraft.font, graphics, skillText, 132, x, y, Color.GRAY.getRGB()); } + graphics.pose().popPose(); } + @Override + public int getHeight() { + return 103; + } - @NotNull @Override - public IDrawable getBackground() { - return this.background; + public int getWidth() { + return 120; } @NotNull diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/AlchemyTableRecipeCategory.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/AlchemyTableRecipeCategory.java index ebf61a486..17cb73d56 100644 --- a/src/main/java/de/teamlapen/vampirism/modcompat/jei/AlchemyTableRecipeCategory.java +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/AlchemyTableRecipeCategory.java @@ -1,13 +1,11 @@ package de.teamlapen.vampirism.modcompat.jei; 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; -import de.teamlapen.vampirism.util.OilUtils; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.drawable.IDrawable; @@ -63,10 +61,14 @@ public Component getTitle() { return this.localizedName; } - @NotNull @Override - public IDrawable getBackground() { - return this.background; + public int getWidth() { + return 149; + } + + @Override + public int getHeight() { + return 110; } @NotNull @@ -88,6 +90,8 @@ public void setRecipe(@NotNull IRecipeLayoutBuilder builder, @NotNull RecipeHold @Override public void draw(@NotNull RecipeHolder holder, IRecipeSlotsView recipeSlotsView, @NotNull GuiGraphics graphics, double mouseX, double mouseY) { + this.background.draw(graphics); + graphics.pose().pushPose(); AlchemyTableRecipe recipe = holder.value(); this.blazeHeat.draw(graphics, 33 - 9 - 2, 60 - 10 - 2); this.arrow.draw(graphics, 73 - 9 - 2, 57 - 10 - 2); @@ -112,5 +116,7 @@ public void draw(@NotNull RecipeHolder holder, IRecipeSlotsV y += UtilLib.renderMultiLine(minecraft.font, graphics, skillText, 132, x, y, Color.gray.getRGB()); } + + graphics.pose().popPose(); } } diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/BlessingRecipeCategory.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/BlessingRecipeCategory.java index bf2e8dbf7..c4e800b5d 100644 --- a/src/main/java/de/teamlapen/vampirism/modcompat/jei/BlessingRecipeCategory.java +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/BlessingRecipeCategory.java @@ -1,6 +1,5 @@ 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; @@ -17,7 +16,6 @@ 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; @@ -44,9 +42,15 @@ public BlessingRecipeCategory(@NotNull IGuiHelper guiHelper) { return Component.translatable("text.vampirism.blessing"); } + + @Override + public int getWidth() { + return 123; + } + @Override - public IDrawable getBackground() { - return background; + public int getHeight() { + return 79; } @Override @@ -56,11 +60,14 @@ public IDrawable getIcon() { @Override public void draw(BlessableItem.@NotNull Recipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics graphics, double mouseX, double mouseY) { + background.draw(graphics); + graphics.pose().pushPose(); if (recipe.enhanced()) { Minecraft minecraft = Minecraft.getInstance(); graphics.drawString(minecraft.font, Component.translatable("gui.vampirism.skill_required"), 15, 52, Color.gray.getRGB(), false); graphics.drawString(minecraft.font, HunterSkills.ENHANCED_BLESSING.get().getName(), 15, 52 + minecraft.font.lineHeight + 2, Color.gray.getRGB(), false); } + graphics.pose().popPose(); } @Override diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/BloodSieveRecipeCategory.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/BloodSieveRecipeCategory.java index 8ea975d73..fdd48ec6a 100644 --- a/src/main/java/de/teamlapen/vampirism/modcompat/jei/BloodSieveRecipeCategory.java +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/BloodSieveRecipeCategory.java @@ -1,15 +1,14 @@ package de.teamlapen.vampirism.modcompat.jei; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; import de.teamlapen.vampirism.api.util.VResourceLocation; +import de.teamlapen.vampirism.client.gui.screens.AlchemicalCauldronScreen; import de.teamlapen.vampirism.core.ModBlocks; import de.teamlapen.vampirism.core.ModFluids; import de.teamlapen.vampirism.modcompat.jei.recipes.BloodSieveRecipe; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawableAnimated; +import mezz.jei.api.gui.drawable.IDrawableStatic; import mezz.jei.api.gui.ingredient.IRecipeSlotsView; import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.recipe.IFocusGroup; @@ -22,8 +21,9 @@ import net.neoforged.neoforge.fluids.FluidType; import org.jetbrains.annotations.NotNull; +import static de.teamlapen.vampirism.modcompat.jei.AlchemicalCauldronRecipeCategory.fixSprite; + public class BloodSieveRecipeCategory implements IRecipeCategory { - private static final ResourceLocation PROGRESS = VResourceLocation.loc("jei", "textures/jei/gui/gui_vanilla.png"); private static final ResourceLocation BACKGROUND = VResourceLocation.mod("textures/gui/container/blood_grinder_jei.png"); public static final int width = 78; public static final int height = 18; @@ -32,22 +32,15 @@ public class BloodSieveRecipeCategory implements IRecipeCategory cachedArrows; + private final @NotNull IDrawableAnimated arrow; public BloodSieveRecipeCategory(IGuiHelper guiHelper) { this.background = guiHelper.drawableBuilder(BACKGROUND, 0, 0, width, height).setTextureSize(width, height).build(); this.slot = guiHelper.getSlotDrawable(); this.icon = guiHelper.createDrawableItemStack(ModBlocks.BLOOD_SIEVE.toStack()); - this.localizedName = Component.translatable("block.vampirism.blood_grinder"); - this.cachedArrows = CacheBuilder.newBuilder() - .maximumSize(25) - .build(new CacheLoader<>() { - @Override - public @NotNull IDrawableAnimated load(@NotNull Integer cookTime) { - return guiHelper.drawableBuilder(PROGRESS, 82, 128, 24, 17) - .buildAnimated(cookTime, IDrawableAnimated.StartDirection.LEFT, false); - } - }); + this.localizedName = Component.translatable("block.vampirism.blood_sieve"); + 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); } @Override @@ -61,8 +54,13 @@ public BloodSieveRecipeCategory(IGuiHelper guiHelper) { } @Override - public @NotNull IDrawable getBackground() { - return this.background; + public int getHeight() { + return height; + } + + @Override + public int getWidth() { + return width; } @Override @@ -81,7 +79,10 @@ public void setRecipe(IRecipeLayoutBuilder builder, BloodSieveRecipe recipe, @No @Override public void draw(@NotNull BloodSieveRecipe recipe, @NotNull IRecipeSlotsView recipeSlotsView, @NotNull GuiGraphics guiGraphics, double mouseX, double mouseY) { + this.background.draw(guiGraphics); + guiGraphics.pose().pushPose(); this.slot.draw(guiGraphics); - this.cachedArrows.getUnchecked(50).draw(guiGraphics, 26, 1); + this.arrow.draw(guiGraphics, 26, 1); + guiGraphics.pose().popPose(); } } diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/GrinderRecipeCategory.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/GrinderRecipeCategory.java index e75534153..8a80608e7 100644 --- a/src/main/java/de/teamlapen/vampirism/modcompat/jei/GrinderRecipeCategory.java +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/GrinderRecipeCategory.java @@ -44,8 +44,13 @@ public GrinderRecipeCategory(IGuiHelper guiHelper) { } @Override - public @NotNull IDrawable getBackground() { - return this.background; + public int getHeight() { + return height; + } + + @Override + public int getWidth() { + return width; } @Override @@ -61,6 +66,8 @@ public void setRecipe(IRecipeLayoutBuilder builder, GrinderRecipe recipe, @NotNu @Override public void draw(GrinderRecipe recipe, @NotNull IRecipeSlotsView recipeSlotsView, @NotNull GuiGraphics guiGraphics, double mouseX, double mouseY) { + this.background.draw(guiGraphics); + guiGraphics.pose().pushPose(); this.slot.draw(guiGraphics); int blood = recipe.itemBlood().blood(); @@ -68,5 +75,6 @@ public void draw(GrinderRecipe recipe, @NotNull IRecipeSlotsView recipeSlotsView MutableComponent text = Component.translatable("gui.vampirism.jei.category.grinder.blood", blood); guiGraphics.drawString(Minecraft.getInstance().font, text, 24, 5, 0xFF808080, false); + guiGraphics.pose().popPose(); } } diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/PotionTableRecipeCategory.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/PotionTableRecipeCategory.java index 5754a284d..20e10b558 100644 --- a/src/main/java/de/teamlapen/vampirism/modcompat/jei/PotionTableRecipeCategory.java +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/PotionTableRecipeCategory.java @@ -5,7 +5,6 @@ import de.teamlapen.vampirism.core.ModBlocks; import de.teamlapen.vampirism.entity.player.hunter.skills.HunterSkills; import mezz.jei.api.constants.VanillaTypes; -import mezz.jei.api.gui.ITickTimer; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawableAnimated; @@ -56,6 +55,8 @@ private static ResourceLocation fixSprite(ResourceLocation spriteLoc) { @Override public void draw(@NotNull JEIPotionMix recipe, @NotNull IRecipeSlotsView recipeSlotsView, @NotNull GuiGraphics graphics, double mouseX, double mouseY) { + this.background.draw(graphics); + graphics.pose().pushPose(); this.blazeHeat.draw(graphics, 1, 35); this.bubbles.draw(graphics, 3, 4); this.arrow.draw(graphics, 80, 10); @@ -81,12 +82,17 @@ public void draw(@NotNull JEIPotionMix recipe, @NotNull IRecipeSlotsView recipeS graphics.drawString(minecraft.font, HunterSkills.EFFICIENT_BREWING.get().getName(), x, y, Color.GRAY.getRGB(), false); y += minecraft.font.lineHeight; } + graphics.pose().popPose(); + } + + @Override + public int getWidth() { + return 128; } - @NotNull @Override - public IDrawable getBackground() { - return background; + public int getHeight() { + return 106; } @NotNull @@ -116,21 +122,4 @@ public void setRecipe(@NotNull IRecipeLayoutBuilder builder, @NotNull JEIPotionM builder.addSlot(RecipeIngredientRole.OUTPUT, 105, 15).addItemStack(recipe.getPotionOutput()).setBackground(this.slotDrawable, -1, -1); } - private static class BrewingBubblesTickTimer implements ITickTimer { - private static final int[] BUBBLE_LENGTHS = new int[] {29, 23, 18, 13, 9, 5, 0}; - private final @NotNull ITickTimer internalTimer; - - public BrewingBubblesTickTimer(@NotNull IGuiHelper guiHelper) { - this.internalTimer = guiHelper.createTickTimer(14, BUBBLE_LENGTHS.length - 1, false); - } - - public int getMaxValue() { - return BUBBLE_LENGTHS[0]; - } - - public int getValue() { - int timerValue = this.internalTimer.getValue(); - return BUBBLE_LENGTHS[timerValue]; - } - } } diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/TaskRecipeCategory.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/TaskRecipeCategory.java index 2ece4d008..5c63554b5 100644 --- a/src/main/java/de/teamlapen/vampirism/modcompat/jei/TaskRecipeCategory.java +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/TaskRecipeCategory.java @@ -46,6 +46,9 @@ public TaskRecipeCategory(@NotNull IGuiHelper guiHelper) { @Override public void draw(@NotNull Task task, @NotNull IRecipeSlotsView recipeSlotsView, @NotNull GuiGraphics graphics, double mouseX, double mouseY) { + + this.background.draw(graphics); + graphics.pose().pushPose(); Minecraft minecraft = Minecraft.getInstance(); int x = 4; int y = 40; @@ -66,13 +69,17 @@ public void draw(@NotNull Task task, @NotNull IRecipeSlotsView recipeSlotsView, prerequisites.append(Component.translatable("text.vampirism.task.prerequisites.none")); } y += UtilLib.renderMultiLine(minecraft.font, graphics, prerequisites, 160, x, y, Color.GRAY.getRGB()); + graphics.pose().popPose(); + } + @Override + public int getHeight() { + return 122; } - @NotNull @Override - public IDrawable getBackground() { - return background; + public int getWidth() { + return 168; } @NotNull diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/VampirismJEIPlugin.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/VampirismJEIPlugin.java index 403e70a2d..d8b1c4cd7 100755 --- a/src/main/java/de/teamlapen/vampirism/modcompat/jei/VampirismJEIPlugin.java +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/VampirismJEIPlugin.java @@ -20,7 +20,6 @@ import de.teamlapen.vampirism.inventory.WeaponTableMenu; import de.teamlapen.vampirism.items.BlessableItem; import de.teamlapen.vampirism.items.component.AppliedOilContent; -import de.teamlapen.vampirism.items.component.BottleBlood; import de.teamlapen.vampirism.items.component.OilContent; import de.teamlapen.vampirism.modcompat.jei.categories.FogDiffuserRecipeCategory; import de.teamlapen.vampirism.modcompat.jei.categories.GarlicDiffuserRecipeCategory; @@ -32,6 +31,9 @@ import de.teamlapen.vampirism.modcompat.jei.recipes.maker.FogDiffuserRecipeMaker; import de.teamlapen.vampirism.modcompat.jei.recipes.maker.GarlicDiffuserRecipeMaker; import de.teamlapen.vampirism.modcompat.jei.recipes.maker.GrinderRecipeMaker; +import de.teamlapen.vampirism.modcompat.jei.subtypes.BloodBottleInterpreter; +import de.teamlapen.vampirism.modcompat.jei.subtypes.BloodContainerInterpreter; +import de.teamlapen.vampirism.modcompat.jei.subtypes.ContainedOilInterpreter; import de.teamlapen.vampirism.recipes.AlchemicalCauldronRecipe; import de.teamlapen.vampirism.recipes.AlchemyTableRecipe; import de.teamlapen.vampirism.util.OilUtils; @@ -40,8 +42,6 @@ import mezz.jei.api.JeiPlugin; import mezz.jei.api.constants.RecipeTypes; import mezz.jei.api.helpers.IGuiHelper; -import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter; -import mezz.jei.api.ingredients.subtypes.UidContext; import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.vanilla.IJeiAnvilRecipe; import mezz.jei.api.recipe.vanilla.IVanillaRecipeFactory; @@ -52,7 +52,6 @@ import net.minecraft.core.NonNullList; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -135,32 +134,9 @@ public void registerRecipeTransferHandlers(@NotNull IRecipeTransferRegistration @Override public void registerItemSubtypes(@NotNull ISubtypeRegistration registration) { - registration.registerSubtypeInterpreter(ModItems.OIL_BOTTLE.get(), OilNBT.INSTANCE); - registration.registerSubtypeInterpreter(ModItems.BLOOD_BOTTLE.get(), BloodNBT.INSTANCE); - } - - private static class OilNBT implements IIngredientSubtypeInterpreter { - public static final OilNBT INSTANCE = new OilNBT(); - - private OilNBT() { - } - - @Override - public @NotNull String apply(@NotNull ItemStack itemStack, @NotNull UidContext context) { - return Optional.ofNullable(itemStack.get(ModDataComponents.OIL)).map(OilContent::oil).flatMap(Holder::unwrapKey).map(ResourceKey::location).map(ResourceLocation::toString).orElse(IIngredientSubtypeInterpreter.NONE); - } - } - - private static class BloodNBT implements IIngredientSubtypeInterpreter { - public static final BloodNBT INSTANCE = new BloodNBT(); - - private BloodNBT() { - } - - @Override - public @NotNull String apply(@NotNull ItemStack itemStack, @NotNull UidContext context) { - return Optional.ofNullable(itemStack.get(ModDataComponents.BOTTLE_BLOOD)).map(BottleBlood::blood).map(Object::toString).orElse(IIngredientSubtypeInterpreter.NONE); - } + registration.registerSubtypeInterpreter(ModItems.OIL_BOTTLE.get(), new ContainedOilInterpreter()); + registration.registerSubtypeInterpreter(ModItems.BLOOD_BOTTLE.get(), new BloodBottleInterpreter()); + registration.registerSubtypeInterpreter(ModBlocks.BLOOD_CONTAINER.asItem(), new BloodContainerInterpreter()); } @Override diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/WeaponTableRecipeCategory.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/WeaponTableRecipeCategory.java index 86578090d..8467ae2c1 100644 --- a/src/main/java/de/teamlapen/vampirism/modcompat/jei/WeaponTableRecipeCategory.java +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/WeaponTableRecipeCategory.java @@ -54,6 +54,8 @@ public class WeaponTableRecipeCategory implements IRecipeCategory holder, @NotNull IRecipeSlotsView recipeSlotsView, @NotNull GuiGraphics graphics, double mouseX, double mouseY) { + this.background.draw(graphics); + graphics.pose().pushPose(); IWeaponTableRecipe recipe = holder.value(); int x = 2; @@ -86,12 +88,17 @@ public void draw(@NotNull RecipeHolder holder, @NotNull IRec y += UtilLib.renderMultiLine(minecraft.font, graphics, skillText, 132, x, y, Color.GRAY.getRGB()); } + graphics.pose().popPose(); + } + + @Override + public int getHeight() { + return 110; } - @NotNull @Override - public IDrawable getBackground() { - return background; + public int getWidth() { + return 134; } @NotNull diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/categories/FogDiffuserRecipeCategory.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/categories/FogDiffuserRecipeCategory.java index 4f97e370b..9137722ad 100644 --- a/src/main/java/de/teamlapen/vampirism/modcompat/jei/categories/FogDiffuserRecipeCategory.java +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/categories/FogDiffuserRecipeCategory.java @@ -44,8 +44,13 @@ public FogDiffuserRecipeCategory(IGuiHelper guiHelper) { } @Override - public @NotNull IDrawable getBackground() { - return this.background; + public int getWidth() { + return width; + } + + @Override + public int getHeight() { + return height; } @Override @@ -61,6 +66,8 @@ public void setRecipe(IRecipeLayoutBuilder builder, FogDiffuserRecipe recipe, @N @Override public void draw(FogDiffuserRecipe recipe, @NotNull IRecipeSlotsView recipeSlotsView, @NotNull GuiGraphics guiGraphics, double mouseX, double mouseY) { + this.background.draw(guiGraphics); + guiGraphics.pose().pushPose(); this.slot.draw(guiGraphics); int burnDuration = recipe.getBurnTime() / 20; @@ -74,5 +81,6 @@ public void draw(FogDiffuserRecipe recipe, @NotNull IRecipeSlotsView recipeSlots } guiGraphics.drawString(Minecraft.getInstance().font, text, 24, 5, 0xFF808080, false); + guiGraphics.pose().popPose(); } } diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/categories/GarlicDiffuserRecipeCategory.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/categories/GarlicDiffuserRecipeCategory.java index 9c9a0f44b..c202eba88 100644 --- a/src/main/java/de/teamlapen/vampirism/modcompat/jei/categories/GarlicDiffuserRecipeCategory.java +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/categories/GarlicDiffuserRecipeCategory.java @@ -44,8 +44,13 @@ public GarlicDiffuserRecipeCategory(IGuiHelper guiHelper) { } @Override - public @NotNull IDrawable getBackground() { - return this.background; + public int getHeight() { + return height; + } + + @Override + public int getWidth() { + return width; } @Override @@ -61,6 +66,8 @@ public void setRecipe(IRecipeLayoutBuilder builder, GarlicDiffuserRecipe recipe, @Override public void draw(GarlicDiffuserRecipe recipe, @NotNull IRecipeSlotsView recipeSlotsView, @NotNull GuiGraphics guiGraphics, double mouseX, double mouseY) { + this.background.draw(guiGraphics); + guiGraphics.pose().pushPose(); this.slot.draw(guiGraphics); int burnDuration = recipe.getBurnTime() / 20; @@ -74,5 +81,6 @@ public void draw(GarlicDiffuserRecipe recipe, @NotNull IRecipeSlotsView recipeSl } guiGraphics.drawString(Minecraft.getInstance().font, text, 24, 5, 0xFF808080, false); + guiGraphics.pose().popPose(); } } diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/subtypes/BloodBottleInterpreter.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/subtypes/BloodBottleInterpreter.java new file mode 100644 index 000000000..7721d66ae --- /dev/null +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/subtypes/BloodBottleInterpreter.java @@ -0,0 +1,24 @@ +package de.teamlapen.vampirism.modcompat.jei.subtypes; + +import de.teamlapen.vampirism.core.ModDataComponents; +import de.teamlapen.vampirism.items.component.BottleBlood; +import mezz.jei.api.ingredients.subtypes.ISubtypeInterpreter; +import mezz.jei.api.ingredients.subtypes.UidContext; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; + +public class BloodBottleInterpreter implements ISubtypeInterpreter { + + @Override + public @Nullable Object getSubtypeData(ItemStack ingredient, @NotNull UidContext context) { + return ingredient.get(ModDataComponents.BOTTLE_BLOOD); + } + + @Override + public @NotNull String getLegacyStringSubtypeInfo(ItemStack ingredient, @NotNull UidContext context) { + return Optional.ofNullable(ingredient.get(ModDataComponents.BOTTLE_BLOOD)).map(BottleBlood::blood).map(Object::toString).orElse(""); + } +} diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/subtypes/BloodContainerInterpreter.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/subtypes/BloodContainerInterpreter.java new file mode 100644 index 000000000..747dd2326 --- /dev/null +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/subtypes/BloodContainerInterpreter.java @@ -0,0 +1,25 @@ +package de.teamlapen.vampirism.modcompat.jei.subtypes; + +import de.teamlapen.vampirism.core.ModDataComponents; +import de.teamlapen.vampirism.items.component.ContainedFluid; +import mezz.jei.api.ingredients.subtypes.ISubtypeInterpreter; +import mezz.jei.api.ingredients.subtypes.UidContext; +import net.minecraft.world.item.ItemStack; +import net.neoforged.neoforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; + +public class BloodContainerInterpreter implements ISubtypeInterpreter { + + @Override + public @Nullable Object getSubtypeData(ItemStack ingredient, @NotNull UidContext context) { + return ingredient.get(ModDataComponents.BLOOD_CONTAINER); + } + + @Override + public @NotNull String getLegacyStringSubtypeInfo(ItemStack ingredient, @NotNull UidContext context) { + return Optional.ofNullable(ingredient.get(ModDataComponents.BLOOD_CONTAINER)).map(ContainedFluid::fluid).map(FluidStack::getAmount).map(String::valueOf).orElse(""); + } +} diff --git a/src/main/java/de/teamlapen/vampirism/modcompat/jei/subtypes/ContainedOilInterpreter.java b/src/main/java/de/teamlapen/vampirism/modcompat/jei/subtypes/ContainedOilInterpreter.java new file mode 100644 index 000000000..b843b00c4 --- /dev/null +++ b/src/main/java/de/teamlapen/vampirism/modcompat/jei/subtypes/ContainedOilInterpreter.java @@ -0,0 +1,27 @@ +package de.teamlapen.vampirism.modcompat.jei.subtypes; + +import de.teamlapen.vampirism.core.ModDataComponents; +import de.teamlapen.vampirism.items.component.OilContent; +import mezz.jei.api.ingredients.subtypes.ISubtypeInterpreter; +import mezz.jei.api.ingredients.subtypes.UidContext; +import net.minecraft.core.Holder; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; + +public class ContainedOilInterpreter implements ISubtypeInterpreter { + + @Override + public @Nullable Object getSubtypeData(ItemStack ingredient, UidContext context) { + return ingredient.get(ModDataComponents.OIL); + } + + @Override + public @NotNull String getLegacyStringSubtypeInfo(ItemStack ingredient, @NotNull UidContext context) { + return Optional.ofNullable(ingredient.get(ModDataComponents.OIL)).map(OilContent::oil).flatMap(Holder::unwrapKey).map(ResourceKey::location).map(ResourceLocation::toString).orElse(""); + } +}