EmperorZelos Posted October 10, 2014 Posted October 10, 2014 I work on my crafting table and I get it to produce anything I so want but none of the resources are being removed, I am a bit stumped and don't even know where to look in the code. Got any hints what part could be the culprit? I got a container for it, dedicated manager for the custom recipies for it and such, I am not sure which code would give you the correct information so do tell what would help you get an idea and I'll gladly post it, as it is a bit much of code I don't post it all right now. Quote
EmperorZelos Posted October 10, 2014 Author Posted October 10, 2014 Shall be provided! Container package aerosteam.container; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import aerosteam.crafting.AnvilSmithManager; import aerosteam.items.ItemsAS; import aerosteam.tileentity.TileEntityAnvil; import aerosteam.tileentity.TileEntitySmelter; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; 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.inventory.SlotFurnace; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.world.World; public class ContainerAnvil extends Container { private TileEntityAnvil anvil; private World worldObj; private int posX; private int posY; private int posZ; public InventoryCrafting craftMatrix; public IInventory craftResult; public ContainerAnvil(InventoryPlayer inventory,TileEntityAnvil tileentity, World world, int x, int y, int z){ this.anvil=tileentity; craftMatrix = new InventoryCrafting(this, 2,3); craftResult = new InventoryCraftResult(); worldObj=world; this.posX=x; this.posY=y; this.posZ=z; //Hammer slot this.addSlotToContainer(new Slot(tileentity,0,116,13)); for (int i = 0; i<2;i++){ for (int j = 0; j<3;j++){ this.addSlotToContainer(new Slot(craftMatrix,(i*3+j),21+18*j,33+18*i)); } } this.addSlotToContainer(new AnvilSlots(inventory.player, craftMatrix,craftResult, 1,136,42)); for(int i=0; i<3;i++){ for(int j=0; j<9;j++){ this.addSlotToContainer(new Slot(inventory,j+i*9+9,7+18*j+1,83+18*i+1 )); } } for(int i=0;i<9;i++){ this.addSlotToContainer(new Slot(inventory,i,8+18*i,142)); } onCraftMatrixChanged(craftMatrix); } public void onCraftMatrixChanged(IInventory inventory){ //System.out.println("Craft Change"); Slot slot = (Slot)this.inventorySlots.get(0); if (slot != null && slot.getHasStack()){ Item item = slot.getStack().getItem(); if (slot.getStack().getItem() != null){ if (slot.getStack().getItem() == ItemsAS.hammerBronze){ //System.out.println("has hammer"); craftResult.setInventorySlotContents(7, AnvilSmithManager.getInstance().findMatchingRecipe(craftMatrix,worldObj)); } } } //System.out.println("Done matching"); } @Override public boolean canInteractWith(EntityPlayer player) { return player.getDistanceSq((double)posX +0.5D, (double)posY+0.5D, (double)posZ+0.5D)<64.0D; } public void addCraftingToCrafter (ICrafting icraft){ super.addCraftingToCrafters(icraft); //icraft.sendProgressBarUpdate(this, 0, this.anvil.cookTime); } public void detectAndSendChanges (){ super.detectAndSendChanges(); for (int i=0; i<this.crafters.size();i++){ ICrafting icraft = (ICrafting) this.crafters.get(i); //if(this.lastCookTime != this.anvil.cookTime){ //icraft.sendProgressBarUpdate(this, 0, this.anvil.burnTime); //} } //this.lastCookTime = this.smelter.cookTime; } @SideOnly(Side.CLIENT) public void updateProgressBar (int slot, int newValue) { //if (slot==0) this.anvil.burnTime=newValue; } public ItemStack transferStackInSlot(EntityPlayer player, int i) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(i); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (i == 3) { if (!this.mergeItemStack(itemstack1, 4, 39, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (i != 1 && i != 0 && i != 2) { if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null) { if (!this.mergeItemStack(itemstack1, 1, 2, false)) { return null; } } else if (TileEntityFurnace.isItemFuel(itemstack1)) { if (!this.mergeItemStack(itemstack1, 0, 3, false)) { return null; } } else if (i >= 3 && i < 30) { if (!this.mergeItemStack(itemstack1, 30, 39, false)) { return null; } } else if (i >= 30 && i < 39 && !this.mergeItemStack(itemstack1, 4, 30, false)) { return null; } } else if (!this.mergeItemStack(itemstack1, 4, 39, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize == itemstack.stackSize) { return null; } slot.onPickupFromSlot(player, itemstack1); } return itemstack; } public void onContainerClosed(EntityPlayer p_75134_1_) { super.onContainerClosed(p_75134_1_); if (!this.worldObj.isRemote) { for (int i = 0; i < 6; ++i) { ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); if (itemstack != null) { p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); } } } } } Gui: package aerosteam.gui; import org.lwjgl.opengl.GL11; import aerosteam.AeroSteam; import aerosteam.tileentity.TileEntityAnvil; import aerosteam.tileentity.TileEntitySmelter; import aerosteam.container.ContainerAnvil; import aerosteam.container.ContainerSmelter; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.util.ResourceLocation; public class GuiAnvil extends GuiContainer{ public static final ResourceLocation bground=new ResourceLocation(AeroSteam.MODID + ":" + "textures/gui/Anvil.png"); public TileEntityAnvil anvil; public GuiAnvil(InventoryPlayer inventoryPlayer,TileEntityAnvil entity, int x, int y, int z) { super(new ContainerAnvil(inventoryPlayer,entity,entity.getWorldObj(), x,y,z)); this.anvil=entity; this.xSize=176; this.ySize=166; } private static Container ContainerAbil(InventoryPlayer inventoryPlayer, TileEntityAnvil entity) { // TODO Auto-generated method stub return null; } public void drawGuiContainerForegroundLayer(int x, int y){ String name="Anvil"; //String name=this.smelter.hasCustomInventoryName() ? this.smelter.getInventoryName():I18n.format(this.smelter.getInventoryName(),new Object[0]); this.fontRendererObj.drawString(name, this.xSize/2-this.fontRendererObj.getStringWidth(name)/2, 4, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory",new Object[0]),120,this.ySize-96+2,4210752); } @Override protected void drawGuiContainerBackgroundLayer(float var1,int var2, int var3) { GL11.glColor4f(1F,1F,1F,1F); Minecraft.getMinecraft().getTextureManager().bindTexture(bground); drawTexturedModalRect(guiLeft,guiTop,0,0,this.xSize,this.ySize); /*if(this.smelter.isBurning()){ this.fontRendererObj.drawString("true", this.xSize/2+40, this.ySize-96+2, 4210752); }else{ int shit = this.smelter.burnTime; this.fontRendererObj.drawString("false:" + String.valueOf(shit) , this.xSize/2+40, this.ySize-96+2, 4210752); }*/ /*if(this.anvil.isBurning()){ int k=this.smelter.getBurnTimeRemainingScaled(14); drawTexturedModalRect(guiLeft+35, guiTop+40+14-k, 176, 28+14-k, 14 , k); } int i=this.smelter.getCookProgressScaled(26); drawTexturedModalRect(guiLeft+81, guiTop+19, 177, 42, 18 , i);*/ } } Gui Handler: package aerosteam.handler; import aerosteam.AeroSteam; import aerosteam.container.ContainerAnvil; import aerosteam.container.ContainerBarrel; import aerosteam.container.ContainerBoiler; import aerosteam.container.ContainerGrinder; import aerosteam.container.ContainerMelter; import aerosteam.container.ContainerSmelter; import aerosteam.container.ContainerWoodenFurnace; import aerosteam.gui.GuiAnvil; import aerosteam.gui.GuiBarrel; import aerosteam.gui.GuiBoiler; import aerosteam.gui.GuiGrinder; import aerosteam.gui.GuiMelter; import aerosteam.gui.GuiSmelter; import aerosteam.gui.GuiWoodenFurnace; import aerosteam.tileentity.TileEntityAnvil; import aerosteam.tileentity.TileEntityBarrel; import aerosteam.tileentity.TileEntityBoiler; import aerosteam.tileentity.TileEntityGrinder; import aerosteam.tileentity.TileEntityMelter; import aerosteam.tileentity.TileEntitySmelter; import aerosteam.tileentity.TileEntityWoodenFurnace; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity=world.getTileEntity(x, y, z); if (entity != null){ switch (ID){ case AeroSteam.guiIDSmelter: if(entity instanceof TileEntitySmelter){ return new ContainerSmelter(player.inventory,(TileEntitySmelter) entity); } case AeroSteam.guiIDMelter: if(entity instanceof TileEntityMelter){ return new ContainerMelter(player.inventory,(TileEntityMelter) entity); } case AeroSteam.guiIDBoiler: if(entity instanceof TileEntityBoiler){ return new ContainerBoiler(player.inventory,(TileEntityBoiler) entity); } case AeroSteam.guiIDBarrel: if(entity instanceof TileEntityBarrel){ return new ContainerBarrel(player.inventory,(TileEntityBarrel) entity); } case AeroSteam.guiIDAnvilBronze: if(entity instanceof TileEntityAnvil){ return new ContainerAnvil(player.inventory,(TileEntityAnvil) entity, world, x, y, z); } case AeroSteam.guiIDGrinder: if(entity instanceof TileEntityGrinder){ return new ContainerGrinder(player.inventory,(TileEntityGrinder) entity); } case AeroSteam.guiIDWoodenFurnace: if(entity instanceof TileEntityWoodenFurnace){ return new ContainerWoodenFurnace(player.inventory,(TileEntityWoodenFurnace) entity); } } } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity=world.getTileEntity(x, y, z); if (entity != null){ switch (ID){ case AeroSteam.guiIDSmelter: if(entity instanceof TileEntitySmelter){ return new GuiSmelter(player.inventory,(TileEntitySmelter) entity); } case AeroSteam.guiIDMelter: if(entity instanceof TileEntityMelter){ return new GuiMelter(player.inventory,(TileEntityMelter) entity); } case AeroSteam.guiIDBoiler: if(entity instanceof TileEntityBoiler){ return new GuiBoiler(player.inventory,(TileEntityBoiler) entity); } case AeroSteam.guiIDBarrel: if(entity instanceof TileEntityBarrel){ return new GuiBarrel(player.inventory,(TileEntityBarrel) entity); } case AeroSteam.guiIDAnvilBronze: if(entity instanceof TileEntityAnvil){ return new GuiAnvil(player.inventory,(TileEntityAnvil) entity, x, y, z); } case AeroSteam.guiIDGrinder: if(entity instanceof TileEntityGrinder){ return new GuiGrinder(player.inventory,(TileEntityGrinder) entity); } case AeroSteam.guiIDWoodenFurnace: if(entity instanceof TileEntityWoodenFurnace){ return new GuiWoodenFurnace(player.inventory,(TileEntityWoodenFurnace) entity); } } } return null; } } Quote
EmperorZelos Posted October 10, 2014 Author Posted October 10, 2014 You mean in the container for the crafting grid? How would I use a custom implementation if so? Imma try the slotcrafting first though Quote
Recommended Posts
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.