Posted February 9, 201312 yr Hello, I wanted to know if anyone knew how to make a custom Recipe require Experience to craft, I tried looking for the GUI's for Anvil and Experience Tables but i Couldn't seem to find them. Container package XPCrystals.common.Gui; import XPCrystals.XPCrystals; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ContainerXPCraftingWorkBench extends Container { public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); public IInventory craftResult = new InventoryCraftResult(); private World worldObj; private int posX; private int posY; private int posZ; public ContainerXPCraftingWorkBench(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) { this.worldObj = par2World; this.posX = par3; this.posY = par4; this.posZ = par5; this.addSlotToContainer(new SlotXPCraftingWorkBench(par1InventoryPlayer.player, this.craftMatrix, this.craftResult, 0, 124, 35)); int var6; int var7; for (var6 = 0; var6 < 3; ++var6) { for (var7 = 0; var7 < 3; ++var7) { this.addSlotToContainer(new Slot(this.craftMatrix, var7 + var6 * 3, 30 + var7 * 18, 17 + var6 * 18)); } } for (var6 = 0; var6 < 3; ++var6) { for (var7 = 0; var7 < 9; ++var7) { this.addSlotToContainer(new Slot(par1InventoryPlayer, var7 + var6 * 9 + 9, 8 + var7 * 18, 84 + var6 * 18)); } } for (var6 = 0; var6 < 9; ++var6) { this.addSlotToContainer(new Slot(par1InventoryPlayer, var6, 8 + var6 * 18, 142)); } this.onCraftMatrixChanged(this.craftMatrix); } public void onCraftMatrixChanged(IInventory par1IInventory) { this.craftResult.setInventorySlotContents(0, XPCraftingWorkBenchCraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); } public boolean canInteractWith(EntityPlayer par1EntityPlayer) { return this.worldObj.getBlockId(this.posX, this.posY, this.posZ) != XPCrystals.XPCrystalWorkBench.blockID ? false : par1EntityPlayer.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D; } public void onCraftGuiClosed(EntityPlayer par1EntityPlayer) { super.onCraftGuiClosed(par1EntityPlayer); if (!this.worldObj.isRemote) { for (int var2 = 0; var2 < 9; ++var2) { ItemStack var3 = this.craftMatrix.getStackInSlotOnClosing(var2); if (var3 != null) { par1EntityPlayer.dropPlayerItem(var3); } } } } public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack var3 = null; Slot var4 = (Slot)this.inventorySlots.get(par2); if (var4 != null && var4.getHasStack()) { ItemStack var5 = var4.getStack(); var3 = var5.copy(); if (par2 == 0) { if (!this.mergeItemStack(var5, 10, 46, true)) { return null; } var4.onSlotChange(var5, var3); } else if (par2 >= 10 && par2 < 37) { if (!this.mergeItemStack(var5, 37, 46, false)) { return null; } } else if (par2 >= 37 && par2 < 46) { if (!this.mergeItemStack(var5, 10, 37, false)) { return null; } } else if (!this.mergeItemStack(var5, 10, 46, false)) { return null; } if (var5.stackSize == 0) { var4.putStack((ItemStack)null); } else { var4.onSlotChanged(); } if (var5.stackSize == var3.stackSize) { return null; } var4.onPickupFromSlot(par1EntityPlayer, var5); } return var3; } } the Recipe for a item in the custom WorkBench XPCraftingWorkBenchCraftingManager.getInstance().func_92051_a(new ItemStack(XPCrystals.XPCrystal, 1), new Object[] {"xxx", Character.valueOf('x'), Block.dirt}); Creating the Recipe for the custom WorkBench with XP (Want it to look like this or something like this) XPCraftingWorkBenchCraftingManager.getInstance().func_92051_a(new ItemStack(XPCrystals.XPCrystal, 1), new Object[] {"xxx", Character.valueOf('x'), Block.dirt}, 30 //<---XP Amount); Kinda Need a way for it to Show Green Text or Numbers like you have enough Example Level:30 you dont have enough example Level:30 The WorkBench Gui's Code package XPCrystals.common.Gui; import org.lwjgl.opengl.GL11; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.StatCollector; import net.minecraft.world.World; public class XPCrystalWorkBenchGUI extends GuiContainer { public XPCrystalWorkBenchGUI(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) { super(new ContainerXPCraftingWorkBench(par1InventoryPlayer, par2World, par3, par4, par5)); } /** * Draw the foreground layer for the GuiContainer (everything in front of the items) */ protected void drawGuiContainerForegroundLayer(int par1, int par2) { this.fontRenderer.drawString(StatCollector.translateToLocal("Crystal WorkBench"), 28, 6, 4210752); this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); } /** * Draw the background layer for the GuiContainer (everything behind the items) */ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { int var4 = this.mc.renderEngine.getTexture("/XPCrystals/Images/Guis/XPCraftingTableGui.png"); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture(var4); int var5 = (this.width - this.xSize) / 2; int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); } } How would i incorporate The amount of XP Levels to Craft this
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.