From 0ac091d26b439075ba579699abbf675d672e8ff6 Mon Sep 17 00:00:00 2001 From: Timo Ley Date: Sun, 8 Jan 2023 16:43:34 +0100 Subject: [PATCH] feat: implement auracore infusion recipes --- build.gradle | 2 +- .../container/ContainerInfusionWorkbench.java | 8 +- .../SlotCraftingInfusionWorkbench.java | 5 +- .../gui/GuiInfusionWorkbench.java | 45 ++++++----- .../recipes/InfusionCraftingManager.java | 75 ------------------- 5 files changed, 27 insertions(+), 108 deletions(-) delete mode 100644 src/main/java/net/anvilcraft/classiccasting/recipes/InfusionCraftingManager.java diff --git a/build.gradle b/build.gradle index a7fe79b..9942d8b 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ repositories { dependencies { implementation "thaumcraft:Thaumcraft:1.7.10-4.2.3.5:deobf" - implementation "dev.tilera:auracore:1.3.0:deobf" + implementation "dev.tilera:auracore:1.4.1:deobf" implementation "com.github.tox1cozZ:mixin-booter-legacy:1.1.2" } diff --git a/src/main/java/net/anvilcraft/classiccasting/container/ContainerInfusionWorkbench.java b/src/main/java/net/anvilcraft/classiccasting/container/ContainerInfusionWorkbench.java index e9eff7f..d671c3a 100644 --- a/src/main/java/net/anvilcraft/classiccasting/container/ContainerInfusionWorkbench.java +++ b/src/main/java/net/anvilcraft/classiccasting/container/ContainerInfusionWorkbench.java @@ -4,7 +4,6 @@ import dev.tilera.auracore.api.IWand; import dev.tilera.auracore.api.crafting.IInfusionRecipe; import dev.tilera.auracore.crafting.AuracoreCraftingManager; import net.anvilcraft.classiccasting.WandManager; -import net.anvilcraft.classiccasting.recipes.InfusionCraftingManager; import net.anvilcraft.classiccasting.tiles.TileInfusionWorkbench; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -81,11 +80,10 @@ public class ContainerInfusionWorkbench extends Container { ic, this.tileEntity.getWorldObj() ) ); - + TileMagicWorkbench bridge = AuracoreCraftingManager.createBridgeInventory(this.tileEntity, 0, 9); if (this.tileEntity.getStackInSlot(9) == null && this.tileEntity.getStackInSlot(10) != null && this.tileEntity.getStackInSlot(10).getItem() instanceof IWand) { - TileMagicWorkbench bridge = AuracoreCraftingManager.createBridgeInventory(this.tileEntity, 0, 9); IArcaneRecipe recipe = AuracoreCraftingManager.findMatchingArcaneRecipe(bridge, this.ip.player); if (recipe != null && WandManager.hasCharge(this.tileEntity.getStackInSlot(10), this.ip.player, AuracoreCraftingManager.getArcaneRecipeVisCost(recipe, bridge))) { this.tileEntity.setInventorySlotContentsSoftly( @@ -98,8 +96,8 @@ public class ContainerInfusionWorkbench extends Container { if (this.tileEntity.getStackInSlot(9) == null && this.tileEntity.getStackInSlot(10) != null) { IInfusionRecipe rec - = InfusionCraftingManager.INSTANCE.findMatchingInfusionRecipe( - this.tileEntity, this.ip.player + = AuracoreCraftingManager.findMatchingInfusionRecipe( + bridge, this.ip.player ); if (rec != null diff --git a/src/main/java/net/anvilcraft/classiccasting/container/SlotCraftingInfusionWorkbench.java b/src/main/java/net/anvilcraft/classiccasting/container/SlotCraftingInfusionWorkbench.java index ce53d64..76b495f 100644 --- a/src/main/java/net/anvilcraft/classiccasting/container/SlotCraftingInfusionWorkbench.java +++ b/src/main/java/net/anvilcraft/classiccasting/container/SlotCraftingInfusionWorkbench.java @@ -4,7 +4,6 @@ import cpw.mods.fml.common.FMLCommonHandler; import dev.tilera.auracore.api.crafting.IInfusionRecipe; import dev.tilera.auracore.crafting.AuracoreCraftingManager; import net.anvilcraft.classiccasting.WandManager; -import net.anvilcraft.classiccasting.recipes.InfusionCraftingManager; import net.anvilcraft.classiccasting.tiles.TileInfusionWorkbench; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -47,8 +46,8 @@ public class SlotCraftingInfusionWorkbench extends SlotCrafting { IArcaneRecipe recipe = AuracoreCraftingManager.findMatchingArcaneRecipe(bridge, this.thePlayer); cost = AuracoreCraftingManager.getArcaneRecipeVisCost(recipe, bridge); if (cost == 0) { - IInfusionRecipe rec = InfusionCraftingManager.INSTANCE.findMatchingInfusionRecipe( - this.craftMatrix, this.thePlayer + IInfusionRecipe rec = AuracoreCraftingManager.findMatchingInfusionRecipe( + bridge, this.thePlayer ); if (rec != null) { cost = rec.getCost(); diff --git a/src/main/java/net/anvilcraft/classiccasting/gui/GuiInfusionWorkbench.java b/src/main/java/net/anvilcraft/classiccasting/gui/GuiInfusionWorkbench.java index 445206e..eff6768 100644 --- a/src/main/java/net/anvilcraft/classiccasting/gui/GuiInfusionWorkbench.java +++ b/src/main/java/net/anvilcraft/classiccasting/gui/GuiInfusionWorkbench.java @@ -4,9 +4,9 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import dev.tilera.auracore.api.IWand; import dev.tilera.auracore.api.crafting.IInfusionRecipe; +import dev.tilera.auracore.crafting.AuracoreCraftingManager; import net.anvilcraft.classiccasting.WandManager; import net.anvilcraft.classiccasting.container.ContainerInfusionWorkbench; -import net.anvilcraft.classiccasting.recipes.InfusionCraftingManager; import net.anvilcraft.classiccasting.tiles.TileInfusionWorkbench; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.RenderHelper; @@ -18,8 +18,10 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.crafting.IArcaneRecipe; import thaumcraft.client.lib.UtilsFX; import thaumcraft.codechicken.lib.math.MathHelper; +import thaumcraft.common.tiles.TileMagicWorkbench; @SideOnly(Side.CLIENT) public class GuiInfusionWorkbench extends GuiContainer { @@ -85,17 +87,14 @@ public class GuiInfusionWorkbench extends GuiContainer { this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); GL11.glDisable(3042); ItemStack result = null; - // TODO: arcane crafting - //if (ThaumcraftCraftingManager.findMatchingArcaneRecipe( - // (IInventory) this.tileEntity, this.ip.player - // ) - // != null) { - // result = ThaumcraftCraftingManager.findMatchingArcaneRecipe( - // (IInventory) this.tileEntity, this.ip.player - // ); - //} else - IInfusionRecipe rec = InfusionCraftingManager.INSTANCE.findMatchingInfusionRecipe( - this.tileEntity, this.ip.player + TileMagicWorkbench bridge = AuracoreCraftingManager.createBridgeInventory(this.tileEntity, 0, 9); + IArcaneRecipe arcaneRecipe = AuracoreCraftingManager.findMatchingArcaneRecipe(bridge, this.ip.player); + IInfusionRecipe rec = null; + if (arcaneRecipe != null) { + result = arcaneRecipe.getCraftingResult(bridge); + } else { + rec = AuracoreCraftingManager.findMatchingInfusionRecipe( + bridge, this.ip.player ); if (rec != null) { result = rec.getRecipeOutput(); @@ -124,6 +123,7 @@ public class GuiInfusionWorkbench extends GuiContainer { } } } + } if (this.tileEntity.getStackInSlot(10) != null) { final int charge = ((IWand)this.tileEntity.getStackInSlot(10).getItem()).getVis(this.tileEntity.getStackInSlot(10)); if (charge > 0) { @@ -139,13 +139,11 @@ public class GuiInfusionWorkbench extends GuiContainer { if (result != null) { final int discount = 100 - Math.min(50, WandManager.getTotalVisDiscount(this.ip.player)); - //int cost1 = ThaumcraftCraftingManager.findMatchingArcaneRecipeCost( - // this.tileEntity, this.ip.player - //); - //cost1 = Math.round(cost1 * (discount / 100.0f)); - int cost2 = rec.getCost(); + int cost1 = arcaneRecipe != null ? AuracoreCraftingManager.getArcaneRecipeVisCost(arcaneRecipe, bridge) : 0; + cost1 = Math.round(cost1 * (discount / 100.0f)); + int cost2 = rec != null ? rec.getCost() : 0; cost2 = Math.round(cost2 * (discount / 100.0f)); - if (/*charge < cost1 ||*/ charge < cost2) { + if (charge < cost1 || charge < cost2) { GL11.glPushMatrix(); RenderHelper.enableGUIStandardItemLighting(); GL11.glDisable(2896); @@ -174,10 +172,10 @@ public class GuiInfusionWorkbench extends GuiContainer { GL11.glTranslatef((float) (var5 + 140), (float) (var6 + 85), 0.0f); GL11.glScalef(0.5f, 0.5f, 0.0f); String text2 = "Insufficient charge"; - if (/*cost1 > ((ItemWandCasting) this.tileEntity.getStackInSlot(10) + if (cost1 > ((IWand) this.tileEntity.getStackInSlot(10) .getItem()) - .getMaxVis() - ||*/ cost2 > ((IWand) this.tileEntity.getStackInSlot(10) + .getMaxVis(this.tileEntity.getStackInSlot(10)) + || cost2 > ((IWand) this.tileEntity.getStackInSlot(10) .getItem()) .getMaxVis(this.tileEntity.getStackInSlot(10))) { text2 = "This wand is too weak"; @@ -187,12 +185,11 @@ public class GuiInfusionWorkbench extends GuiContainer { GL11.glScalef(1.0f, 1.0f, 1.0f); GL11.glPopMatrix(); } - if (/*cost1 > 0 ||*/ cost2 > 0) { + if (cost1 > 0 || cost2 > 0) { GL11.glPushMatrix(); GL11.glTranslatef((float) (var5 + 140), (float) (var6 + 81), 0.0f); GL11.glScalef(0.5f, 0.5f, 0.0f); - //final String text2 = Math.max(cost1, cost2) + " vis"; - final String text2 = cost2 + " vis"; + final String text2 = Math.max(cost1, cost2) + " vis"; final int ll2 = this.fontRendererObj.getStringWidth(text2) / 2; this.fontRendererObj.drawStringWithShadow(text2, -ll2, -64, 15658734); GL11.glScalef(1.0f, 1.0f, 1.0f); diff --git a/src/main/java/net/anvilcraft/classiccasting/recipes/InfusionCraftingManager.java b/src/main/java/net/anvilcraft/classiccasting/recipes/InfusionCraftingManager.java deleted file mode 100644 index 710a66c..0000000 --- a/src/main/java/net/anvilcraft/classiccasting/recipes/InfusionCraftingManager.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.anvilcraft.classiccasting.recipes; - -import java.util.ArrayList; -import java.util.List; - -import dev.tilera.auracore.api.crafting.IInfusionRecipe; -import net.anvilcraft.classiccasting.CCBlocks; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.api.aspects.AspectList; - -public class InfusionCraftingManager { - public static InfusionCraftingManager INSTANCE = new InfusionCraftingManager(); - public List recipes = new ArrayList<>(); - - public InfusionCraftingManager() { - this.recipes.add(new IInfusionRecipe() { - @Override - public boolean matches(IInventory var1, World var2, EntityPlayer var3) { - return var1.getStackInSlot(0) != null - && var1.getStackInSlot(0).getItem() - == Items.gold_nugget; - } - - @Override - public ItemStack getCraftingResult(IInventory var1) { - return this.getRecipeOutput(); - } - - @Override - public int getRecipeSize() { - return 9; - } - - @Override - public ItemStack getRecipeOutput() { - return new ItemStack(CCBlocks.alembic); - } - - @Override - public int getCost() { - return 10; - } - - @Override - public AspectList getAspects() { - return new AspectList().add(Aspect.GREED, 8); - } - - @Override - public String getKey() { - return "alembus"; - } - - @Override - public String getResearch() { - return null; - } - }); - } - - public IInfusionRecipe findMatchingInfusionRecipe(IInventory inv, EntityPlayer pl) { - for (IInfusionRecipe recipe : this.recipes) { - if (recipe.matches(inv, pl.worldObj, pl)) { - return recipe; - } - } - - return null; - } -}