diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3eb85f51..88e8196e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,8 +2,8 @@ minecraft = "1.21.1" neoForge = "21.1.219" ageratum = "0.0.1+build.106" -anvillib = "2.0.0+snapshot.490" -anvilcraft = "1.6.0+snapshot.2087" +anvillib = "2.0.0+snapshot.500" +anvilcraft = "1.6.0+snapshot.2099" jei = "19.32.0.358" jade = "15.3.4+neoforge" modDevGradle = "2.0.140" diff --git a/src/main/java/dev/anvilcraft/pigsplus/integration/jei/AddonJeiPlugin.java b/src/main/java/dev/anvilcraft/pigsplus/integration/jei/AddonJeiPlugin.java index 8aab74a2..78fa1ba2 100644 --- a/src/main/java/dev/anvilcraft/pigsplus/integration/jei/AddonJeiPlugin.java +++ b/src/main/java/dev/anvilcraft/pigsplus/integration/jei/AddonJeiPlugin.java @@ -55,7 +55,7 @@ public void registerRecipes(IRecipeRegistration registration) { @Override public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { - PrecisionElectromagneticProcessingCategory.registerRecipeCatalysts(registration); + PrecisionElectromagneticProcessingCategory.registerRecipeCatalyst(registration); } private static > RecipeType> createRecipeHolderType(String name) { diff --git a/src/main/java/dev/anvilcraft/pigsplus/integration/jei/category/PrecisionElectromagneticProcessingCategory.java b/src/main/java/dev/anvilcraft/pigsplus/integration/jei/category/PrecisionElectromagneticProcessingCategory.java index d9f8ce6a..2f071376 100644 --- a/src/main/java/dev/anvilcraft/pigsplus/integration/jei/category/PrecisionElectromagneticProcessingCategory.java +++ b/src/main/java/dev/anvilcraft/pigsplus/integration/jei/category/PrecisionElectromagneticProcessingCategory.java @@ -1,59 +1,37 @@ package dev.anvilcraft.pigsplus.integration.jei.category; -import com.mojang.blaze3d.vertex.PoseStack; import dev.anvilcraft.pigsplus.init.AddonBlocks; import dev.anvilcraft.pigsplus.init.AddonRecipeTypes; import dev.anvilcraft.pigsplus.integration.jei.AddonJeiPlugin; import dev.anvilcraft.pigsplus.recipe.PrecisionElectromagneticProcessingRecipe; -import dev.dubhe.anvilcraft.client.support.RenderSupport; -import dev.dubhe.anvilcraft.init.block.ModBlocks; import dev.dubhe.anvilcraft.integration.jei.AnvilCraftJeiPlugin; +import dev.dubhe.anvilcraft.integration.jei.category.anvil.liquid.AbstractLiquidCategory; import dev.dubhe.anvilcraft.integration.jei.drawable.DrawableBlockStateIcon; import dev.dubhe.anvilcraft.integration.jei.util.JeiRecipeUtil; -import dev.dubhe.anvilcraft.integration.jei.util.JeiRenderHelper; -import dev.dubhe.anvilcraft.integration.jei.util.JeiSlotUtil; -import dev.dubhe.anvilcraft.util.CauldronUtil; -import mezz.jei.api.gui.ITickTimer; -import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.builder.ITooltipBuilder; -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.RecipeType; -import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.registration.IRecipeCatalystRegistration; import mezz.jei.api.registration.IRecipeRegistration; import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.RecipeHolder; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; -import org.jetbrains.annotations.Nullable; -public class PrecisionElectromagneticProcessingCategory implements IRecipeCategory> { - public static final int WIDTH = 162; - public static final int HEIGHT = 64; - - private final IDrawable slotDefault; - private final IDrawable slotProbability; - private final Component title; - private final ITickTimer timer; - private final IDrawable arrowIn; - private final IDrawable arrowOut; +public class PrecisionElectromagneticProcessingCategory extends AbstractLiquidCategory { public PrecisionElectromagneticProcessingCategory(IGuiHelper helper) { - slotDefault = JeiRenderHelper.getSlotDefault(helper); - slotProbability = JeiRenderHelper.getSlotProbability(helper); - title = Component.translatable("gui.anvilcraft_pigsplus.category.precision_electromagnetic_processing"); - timer = helper.createTickTimer(30, 60, true); - arrowIn = JeiRenderHelper.getArrowInput(helper); - arrowOut = JeiRenderHelper.getArrowOutput(helper); + super( + helper, + new DrawableBlockStateIcon( + Blocks.CAULDRON.defaultBlockState(), + AddonBlocks.PRECISION_MAGNETIC_PIVOT.getDefaultState() + ), + Component.translatable("gui.anvilcraft_pigsplus.category.precision_electromagnetic_processing") + ); } @Override @@ -62,138 +40,10 @@ public RecipeType> getRec } @Override - public Component getTitle() { - return title; - } - - @Override - public int getWidth() { - return WIDTH; + protected BlockState getProcessBlock() { + return AddonBlocks.PRECISION_MAGNETIC_PIVOT.getDefaultState(); } - @Override - public int getHeight() { - return HEIGHT; - } - - @Override - public @Nullable IDrawable getIcon() { - return new DrawableBlockStateIcon( - Blocks.CAULDRON.defaultBlockState(), - AddonBlocks.PRECISION_MAGNETIC_PIVOT.getDefaultState() - ); - } - - @Override - public void setRecipe( - IRecipeLayoutBuilder builder, RecipeHolder recipeHolder, IFocusGroup focuses) { - PrecisionElectromagneticProcessingRecipe recipe = recipeHolder.value(); - JeiSlotUtil.addInputSlots(builder, recipe.getInputItems()); - if (!recipe.getResultItems().isEmpty()) { - JeiSlotUtil.addOutputSlots(builder, recipe.getResultItems()); - } - } - - @Override - public void draw( - RecipeHolder recipeHolder, - IRecipeSlotsView recipeSlotsView, - GuiGraphics guiGraphics, - double mouseX, - double mouseY - ) { - PrecisionElectromagneticProcessingRecipe recipe = recipeHolder.value(); - float anvilYOffset = JeiRenderHelper.getAnvilAnimationOffset(timer); - RenderSupport.renderBlock( - guiGraphics, - Blocks.ANVIL.defaultBlockState(), - 81, - 12 + anvilYOffset, - 20, - 12, - RenderSupport.SINGLE_BLOCK - ); - Block material = recipe.getHasCauldron().getFluidCauldron(); - RenderSupport.renderBlock( - guiGraphics, - CauldronUtil.fullState(material), - 81, - 30, - 10, - 12, - RenderSupport.SINGLE_BLOCK - ); - - RenderSupport.renderBlock( - guiGraphics, - AddonBlocks.PRECISION_MAGNETIC_PIVOT.getDefaultState(), - 81, - 40, - 0, - 12, - RenderSupport.SINGLE_BLOCK - ); - - if (!recipe.getInputItems().isEmpty()) { - arrowIn.draw(guiGraphics, 54, 20); - } - arrowOut.draw(guiGraphics, 92, 19); - - JeiSlotUtil.drawInputSlots(guiGraphics, slotDefault, recipe.getInputItems().size()); - if (!recipe.getResultItems().isEmpty()) { - if (JeiRecipeUtil.isChance(recipe.getResultItems())) { - JeiSlotUtil.drawOutputSlots(guiGraphics, slotProbability, recipe.getResultItems().size()); - } else { - JeiSlotUtil.drawOutputSlots(guiGraphics, slotDefault, recipe.getResultItems().size()); - } - if (recipe.isConsumeFluid()) { - PoseStack pose = guiGraphics.pose(); - pose.pushPose(); - pose.scale(0.8f, 0.8f, 1.0f); - guiGraphics.drawString( - Minecraft.getInstance().font, - Component.translatable( - "gui.anvilcraft_pigsplus.category.precision_electromagnetic_processing.consume_fluid", - recipe.getHasCauldron().consume(), - material.getName() - ), - 0, - 70, - 0xFF000000, - false - ); - pose.popPose(); - } else if (recipe.isProduceFluid()) { - PoseStack pose = guiGraphics.pose(); - pose.pushPose(); - pose.scale(0.8f, 0.8f, 1.0f); - guiGraphics.drawString( - Minecraft.getInstance().font, - Component.translatable( - "gui.anvilcraft_pigsplus.category.precision_electromagnetic_processing.produce_fluid", - recipe.getHasCauldron().produce(), - recipe.getHasCauldron().getTransformCauldron().getName() - ), - 0, - 70, - 0xFF000000, - false - ); - pose.popPose(); - } - } else { - Block result = recipe.getHasCauldron().getTransformCauldron(); - BlockState cauldronState; - if (recipe.isConsumeFluid()) { - cauldronState = CauldronUtil.getStateFromContentAndLevel(result, CauldronUtil.maxLevel(result) - 1); - } else if (recipe.isProduceFluid()) { - cauldronState = CauldronUtil.getStateFromContentAndLevel(result, 1); - } else { - cauldronState = recipe.getHasCauldron().getTransformCauldron().defaultBlockState(); - } - RenderSupport.renderBlock(guiGraphics, cauldronState, 133, 30, 0, 12, RenderSupport.SINGLE_BLOCK); - } - } @Override public void getTooltip( @@ -203,52 +53,26 @@ public void getTooltip( double mouseX, double mouseY ) { - PrecisionElectromagneticProcessingRecipe recipe = recipeHolder.value(); - if (mouseX >= 72 && mouseX <= 90) { - if (mouseY >= 24 && mouseY <= 43) { - Component text; - if (recipe.isProduceFluid()) { - text = Blocks.CAULDRON.getName(); - } else { - text = recipe.getHasCauldron().getFluidCauldron().getName(); - } - tooltip.add(text); - } - if (mouseY >= 34 && mouseY <= 53) { - tooltip.add(AddonBlocks.PRECISION_MAGNETIC_PIVOT.get().getName()); - tooltip.add(Component.translatable("gui.anvilcraft_pigsplus.category.precision_electromagnetic_processing.need_activated") - .withStyle(ChatFormatting.RED)); - } - } - if (mouseX >= 124 && mouseX <= 140) { - if (mouseY >= 24 && mouseY <= 42) { - Component text; - if (recipe.getResultItems().isEmpty()) { - if (recipe.isConsumeFluid() && CauldronUtil.maxLevel(recipe.getHasCauldron().getTransformCauldron()) <= 1) { - text = Blocks.CAULDRON.getName(); - } else { - text = recipe.getHasCauldron().getTransformCauldron().getName(); - } - tooltip.add(text); - } - } + if (mouseY >= 34 && mouseY <= 53 && mouseX >= 72 && mouseX <= 90) { + tooltip.add(AddonBlocks.PRECISION_MAGNETIC_PIVOT.get().getName()); + tooltip.add(Component.translatable( + "gui.anvilcraft_pigsplus.category.precision_electromagnetic_processing.need_activated" + ).withStyle(ChatFormatting.RED)); } } + public static void registerRecipeCatalyst(IRecipeCatalystRegistration registration) { + AnvilCraftJeiPlugin.addAnvilCauldronCatalysts(registration, AddonJeiPlugin.PRECISION_ELECTROMAGNETIC_PROCESSING); + registration.addRecipeCatalyst( + new ItemStack(AddonBlocks.PRECISION_MAGNETIC_PIVOT), + AddonJeiPlugin.PRECISION_ELECTROMAGNETIC_PROCESSING + ); + } + public static void registerRecipes(IRecipeRegistration registration) { registration.addRecipes( AddonJeiPlugin.PRECISION_ELECTROMAGNETIC_PROCESSING, JeiRecipeUtil.getRecipeHoldersFromType(AddonRecipeTypes.PRECISION_ELECTROMAGNETIC_PROCESSING_TYPE.get()) ); } - - public static void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { - AnvilCraftJeiPlugin.addAnvilProcessingCatalysts(registration, AddonJeiPlugin.PRECISION_ELECTROMAGNETIC_PROCESSING); - registration.addRecipeCatalyst(new ItemStack(Items.CAULDRON), AddonJeiPlugin.PRECISION_ELECTROMAGNETIC_PROCESSING); - registration.addRecipeCatalyst(new ItemStack(ModBlocks.FISH_TANK), AddonJeiPlugin.PRECISION_ELECTROMAGNETIC_PROCESSING); - registration.addRecipeCatalyst( - new ItemStack(AddonBlocks.PRECISION_MAGNETIC_PIVOT.get()), - AddonJeiPlugin.PRECISION_ELECTROMAGNETIC_PROCESSING - ); - } }