I just went in and tested my tutorial table and 5x5 tables adding in new recipes and they work just fine, no issues no glitches. So I am still at a loss to figure out what you guys are doing wrong. Everything works as it should. So until I can get a video proving my point just go back and review my video. The crafting manager works the same in both 3x3 and 5x5 versions....
Mine is the 3x3 crafting table and the only issue im having is that my custom recipes, for only this table, not any other table, are not working.
Id start by going back to the first post and watching my videos for the 3x3 table. Then I would remove the @suppresswarnings from your code and try to figure out by watching my videos why you are getting those yellow lines. And then lastly, I will say it again, use the source code for the vanilla table and copy them over, just like in my video and all should work good. And if you are using items from your mod to craft, you need to make sure you are adding them correctly. This works flawlessly. I have made many tables and furnaces both using the code from in game to recreate them and just making the Necessary changes every time.
I have a slight problem: My gui doesn't open up.
I copied your files and modified them to fit my mod(changed names)
But the gui doesn't open.(If you want to see my codes I'll happily post them)
I love your username and profile pic, eXistenZ was an awesome movie and rpg maker is a fun engine
So I made my own crafting table using the vanilla stuff and it didn't work too great,so I decided to wipe all of my code relating to it and follow your tutorial even so I still have the same problem,recipe outputs don't show.
Vanilla recipes show in the output slot but as soon as I add my own recipe to the table the output is blank,it does work but it just doesn't show.
Only my custom recipes have a blank output,the vanilla ones show the output as they should.
Here's my codes:
Main Class:
package heitage;
import heitagebenches.BlockPrepTable;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeedFood;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = Main_Craft.modid, name = "Heitage", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = {"Heitage"}, packetHandler = PacketHandler.class)
public class Main_Craft
{
@Instance("Heitage")
public static Main_Craft instance;
private GuiHandler guihandler = new GuiHandler();
public static final String modid = "Heitage";
//Blocks
public static Block SweetPotatoCrop;
public static Block PrepTable;
//Items
public static Item SweetPotato;
public static Item SweetBaked;
public static Item InfectedPotato;
public static Item DriedMush;
public static Item Pestle;
public static Item Mortar;
@SidedProxy(clientSide = "heitage.ClientProxy", serverSide = "heitage.CommonProxy")
public static CommonProxy proxy;
@EventHandler
public void load(FMLInitializationEvent event)
{
proxy.registerRenderThings();
NetworkRegistry.instance().registerGuiHandler(this, guihandler);
//Crops
SweetPotatoCrop = (new BlockSweetPotatoCrop(3979)).setUnlocalizedName("potatos").setTextureName("heitage:potatoes");
GameRegistry.registerBlock(SweetPotatoCrop, modid + SweetPotatoCrop.getUnlocalizedName());
LanguageRegistry.addName(SweetPotatoCrop, "");
//Blocks
PrepTable = new BlockPrepTable(3980).setHardness(1.0F).setResistance(200.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("PrepTable").setTextureName("heitage:PrepTable");
GameRegistry.registerBlock(PrepTable, modid + PrepTable.getUnlocalizedName());
LanguageRegistry.addName(PrepTable, "Preporation Table");
//Food
SweetPotato = (new ItemSeedFood(4000, 3, 0.4F, Main_Craft.SweetPotatoCrop.blockID, Block.tilledField.blockID)).setUnlocalizedName("SweetPotato").setCreativeTab(CreativeTabs.tabFood).setTextureName("heitage:SweetPotato");
LanguageRegistry.addName(SweetPotato, "Sweet Potato");
SweetBaked = (new ItemFood(4001, 6, 0.8F, false)).setUnlocalizedName("sweetbaked").setTextureName("heitage:sweetpotatocooked");
LanguageRegistry.addName(SweetBaked, "Baked Sweet Potato");
InfectedPotato = (new ItemFood(4002, 2, 0.1F, false)).setPotionEffect(Potion.hunger.id, 30, 0, 0.8F).setPotionEffect(Potion.poison.id, 10, 0, 0.8F).setUnlocalizedName("infectedpotato").setTextureName("heitage:mutatedpotato");
LanguageRegistry.addName(InfectedPotato, "Mutated Potato");
//Items
DriedMush = new heitems.Mushes(4020).setUnlocalizedName("driedmush");
LanguageRegistry.addName(new ItemStack(DriedMush, 1, 0), "Dried Mushroom");
LanguageRegistry.addName(new ItemStack(DriedMush, 1, 1), "Powdered Dry Mushroom");
LanguageRegistry.addName(new ItemStack(DriedMush, 1, 2), "Fungi Spores");
Pestle = new heitems.Pestle(4021).setUnlocalizedName("Pestle");
LanguageRegistry.addName(Pestle, "Pestle");
Mortar = new heitems.Mortar(4022).setUnlocalizedName("MortarPestle").setContainerItem(Mortar);
LanguageRegistry.addName(Mortar, "Mortar and Pestle");
//new ItemStack(Mortar.setContainerItem(Mortar));
//GameRegistry.addRecipe(new ItemStack(Main_Craft.SweetPotato, 1), new Object[] {"###", Character.valueOf('#'), Item.potato});
RecipeHandler.addRecipes();
}
}
BlockPrepTable:
package heitagebenches;
import heitage.Main_Craft;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
public class BlockPrepTable extends Block
{
@SideOnly(Side.CLIENT)
private Icon workbenchIconTop;
@SideOnly(Side.CLIENT)
private Icon workbenchIconFront;
public BlockPrepTable(int par1)
{
super(par1, Material.wood);
this.setCreativeTab(CreativeTabs.tabDecorations);
}
@SideOnly(Side.CLIENT)
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
public Icon getIcon(int par1, int par2)
{
return par1 == 1 ? this.workbenchIconTop : (par1 == 0 ? Block.planks.getBlockTextureFromSide(par1) : (par1 != 2 && par1 != 4 ? this.blockIcon : this.workbenchIconFront));
}
@SideOnly(Side.CLIENT)
/**
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
* is the only chance you get to register icons.
*/
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side");
this.workbenchIconTop = par1IconRegister.registerIcon(this.getTextureName() + "_top");
this.workbenchIconFront = par1IconRegister.registerIcon(this.getTextureName() + "_front");
}
/**
* Called upon block activation (right click on the block.)
*/
public boolean onBlockActivated(World var1, int var2, int var3, int var4, EntityPlayer player, int var6, float var7, float var8, float var9)
{
if (!player.isSneaking())
{
player.openGui(Main_Craft.instance, 1, var1, var2, var3, var4);
return true;
}
else
{
return false;
}
}
}
ContainerPrepTable:
package heitagebenches;
import heitage.Main_Craft;
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.item.crafting.CraftingManager;
import net.minecraft.world.World;
public class ContainerPrepTable extends Container
{
/** The crafting matrix inventory (3x3). */
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 ContainerPrepTable(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 SlotCrafting(par1InventoryPlayer.player, this.craftMatrix, this.craftResult, 0, 124, 35));
int l;
int i1;
for (l = 0; l < 3; ++l)
{
for (i1 = 0; i1 < 3; ++i1)
{
this.addSlotToContainer(new Slot(this.craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18));
}
}
for (l = 0; l < 3; ++l)
{
for (i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18));
}
}
for (l = 0; l < 9; ++l)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, l, 8 + l * 18, 142));
}
this.onCraftMatrixChanged(this.craftMatrix);
}
/**
* Callback for when the crafting matrix is changed.
*/
public void onCraftMatrixChanged(IInventory par1IInventory)
{
this.craftResult.setInventorySlotContents(1, CraftingManagerPrepTable.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
}
/**
* Called when the container is closed.
*/
public void onContainerClosed(EntityPlayer par1EntityPlayer)
{
super.onContainerClosed(par1EntityPlayer);
if (!this.worldObj.isRemote)
{
for (int i = 0; i < 9; ++i)
{
ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i);
if (itemstack != null)
{
par1EntityPlayer.dropPlayerItem(itemstack);
}
}
}
}
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
return this.worldObj.getBlockId(this.posX, this.posY, this.posZ) != Main_Craft.PrepTable.blockID ? false : par1EntityPlayer.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D;
}
/**
* Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
*/
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
{
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(par2);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (par2 == 0)
{
if (!this.mergeItemStack(itemstack1, 10, 46, true))
{
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (par2 >= 10 && par2 < 37)
{
if (!this.mergeItemStack(itemstack1, 37, 46, false))
{
return null;
}
}
else if (par2 >= 37 && par2 < 46)
{
if (!this.mergeItemStack(itemstack1, 10, 37, false))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 10, 46, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize)
{
return null;
}
slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
}
return itemstack;
}
public boolean func_94530_a(ItemStack par1ItemStack, Slot par2Slot)
{
return par2Slot.inventory != this.craftResult && super.func_94530_a(par1ItemStack, par2Slot);
}
}
GuiPrepTable (note: I use the vanilla gui,that's why the code looks like this):
package heitagebenches;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ContainerWorkbench;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiPrepTable extends GuiContainer
{
private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation("textures/gui/container/crafting_table.png");
public GuiPrepTable(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5)
{
super(new ContainerWorkbench(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(I18n.getString("container.crafting"), 28, 6, 4210752);
this.fontRenderer.drawString(I18n.getString("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)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(craftingTableGuiTextures);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
}
SlotPrepTable:
package heitagebenches;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.AchievementList;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
public class SlotPrepTable extends Slot
{
/** The craft matrix inventory linked to this result slot. */
private final IInventory craftMatrix;
/** The player that is using the GUI where this slot resides. */
private EntityPlayer thePlayer;
/**
* The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset.
*/
private int amountCrafted;
public SlotPrepTable(EntityPlayer par1EntityPlayer, IInventory par2IInventory, IInventory par3IInventory, int par4, int par5, int par6)
{
super(par3IInventory, par4, par5, par6);
this.thePlayer = par1EntityPlayer;
this.craftMatrix = par2IInventory;
}
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
public boolean isItemValid(ItemStack par1ItemStack)
{
return false;
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
* stack.
*/
public ItemStack decrStackSize(int par1)
{
if (this.getHasStack())
{
this.amountCrafted += Math.min(par1, this.getStack().stackSize);
}
return super.decrStackSize(par1);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
* internal count then calls onCrafting(item).
*/
protected void onCrafting(ItemStack par1ItemStack, int par2)
{
this.amountCrafted += par2;
this.onCrafting(par1ItemStack);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
protected void onCrafting(ItemStack par1ItemStack)
{
par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
this.amountCrafted = 0;
if (par1ItemStack.itemID == Block.workbench.blockID)
{
this.thePlayer.addStat(AchievementList.buildWorkBench, 1);
}
else if (par1ItemStack.itemID == Item.pickaxeWood.itemID)
{
this.thePlayer.addStat(AchievementList.buildPickaxe, 1);
}
else if (par1ItemStack.itemID == Block.furnaceIdle.blockID)
{
this.thePlayer.addStat(AchievementList.buildFurnace, 1);
}
else if (par1ItemStack.itemID == Item.hoeWood.itemID)
{
this.thePlayer.addStat(AchievementList.buildHoe, 1);
}
else if (par1ItemStack.itemID == Item.bread.itemID)
{
this.thePlayer.addStat(AchievementList.makeBread, 1);
}
else if (par1ItemStack.itemID == Item.cake.itemID)
{
this.thePlayer.addStat(AchievementList.bakeCake, 1);
}
else if (par1ItemStack.itemID == Item.pickaxeStone.itemID)
{
this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1);
}
else if (par1ItemStack.itemID == Item.swordWood.itemID)
{
this.thePlayer.addStat(AchievementList.buildSword, 1);
}
else if (par1ItemStack.itemID == Block.enchantmentTable.blockID)
{
this.thePlayer.addStat(AchievementList.enchantments, 1);
}
else if (par1ItemStack.itemID == Block.bookShelf.blockID)
{
this.thePlayer.addStat(AchievementList.bookcase, 1);
}
}*/
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
{
GameRegistry.onItemCrafted(par1EntityPlayer, par2ItemStack, craftMatrix);
this.onCrafting(par2ItemStack);
for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
{
ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
if (itemstack1 != null)
{
this.craftMatrix.decrStackSize(i, 1);
if (itemstack1.getItem().hasContainerItem())
{
ItemStack itemstack2 = itemstack1.getItem().getContainerItemStack(itemstack1);
if (itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage())
{
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
itemstack2 = null;
}
if (itemstack2 != null && (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)))
{
if (this.craftMatrix.getStackInSlot(i) == null)
{
this.craftMatrix.setInventorySlotContents(i, itemstack2);
}
else
{
this.thePlayer.dropPlayerItem(itemstack2);
}
}
}
}
}
}
}
package heitagebenches;
import heitage.Main_Craft;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
public class CraftingManagerPrepTable
{
/** The static instance of this class */
private static final CraftingManagerPrepTable instance = new CraftingManagerPrepTable();
/** A list of all the recipes added */
private List recipes = new ArrayList();
/**
* Returns the static instance of this class
*/
public static final CraftingManagerPrepTable getInstance()
{
return instance;
}
private CraftingManagerPrepTable()
{
//this.addRecipe(new ItemStack(Main_Craft.SweetPotato, 1), new Object[] {"###", "W", Character.valueOf('#'), Item.potato, Character.valueOf('W'), Main_Craft.Mortar,1,Short.MAX_VALUE});
this.addRecipe(new ItemStack(Item.paper,3), new Object[] {"###", '#', Item.reed});
this.addRecipe(new ItemStack(Main_Craft.SweetPotato, 1), new Object[] {"##W", Character.valueOf('#'), Item.potato,Character.valueOf('W'),new ItemStack (Main_Craft.Mortar,1,OreDictionary.WILDCARD_VALUE)});
this.addRecipe(new ItemStack(Item.paper,3), new Object[] {"#", '#',new ItemStack (Main_Craft.Mortar,1,OreDictionary.WILDCARD_VALUE)});
Collections.sort(this.recipes, new RecipeSorterPrepTable(this));
}
public ShapedRecipes addRecipe(ItemStack par1ItemStack, Object ... par2ArrayOfObj)
{
String s = "";
int i = 0;
int j = 0;
int k = 0;
if (par2ArrayOfObj[i] instanceof String[])
{
String[] astring = (String[])((String[])par2ArrayOfObj[i++]);
for (int l = 0; l < astring.length; ++l)
{
String s1 = astring[l];
++k;
j = s1.length();
s = s + s1;
}
}
else
{
while (par2ArrayOfObj[i] instanceof String)
{
String s2 = (String)par2ArrayOfObj[i++];
++k;
j = s2.length();
s = s + s2;
}
}
HashMap hashmap;
for (hashmap = new HashMap(); i < par2ArrayOfObj.length; i += 2)
{
Character character = (Character)par2ArrayOfObj[i];
ItemStack itemstack1 = null;
if (par2ArrayOfObj[i + 1] instanceof Item)
{
itemstack1 = new ItemStack((Item)par2ArrayOfObj[i + 1]);
}
else if (par2ArrayOfObj[i + 1] instanceof Block)
{
itemstack1 = new ItemStack((Block)par2ArrayOfObj[i + 1], 1, 32767);
}
else if (par2ArrayOfObj[i + 1] instanceof ItemStack)
{
itemstack1 = (ItemStack)par2ArrayOfObj[i + 1];
}
hashmap.put(character, itemstack1);
}
ItemStack[] aitemstack = new ItemStack[j * k];
for (int i1 = 0; i1 < j * k; ++i1)
{
char c0 = s.charAt(i1);
if (hashmap.containsKey(Character.valueOf(c0)))
{
aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf(c0))).copy();
}
else
{
aitemstack[i1] = null;
}
}
ShapedRecipes shapedrecipes = new ShapedRecipes(j, k, aitemstack, par1ItemStack);
this.recipes.add(shapedrecipes);
return shapedrecipes;
}
public void addShapelessRecipe(ItemStack par1ItemStack, Object ... par2ArrayOfObj)
{
ArrayList arraylist = new ArrayList();
Object[] aobject = par2ArrayOfObj;
int i = par2ArrayOfObj.length;
for (int j = 0; j < i; ++j)
{
Object object1 = aobject[j];
if (object1 instanceof ItemStack)
{
arraylist.add(((ItemStack)object1).copy());
}
else if (object1 instanceof Item)
{
arraylist.add(new ItemStack((Item)object1));
}
else
{
if (!(object1 instanceof Block))
{
throw new RuntimeException("Invalid shapeless recipy!");
}
arraylist.add(new ItemStack((Block)object1));
}
}
this.recipes.add(new ShapelessRecipes(par1ItemStack, arraylist));
}
public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World)
{
int i = 0;
ItemStack itemstack = null;
ItemStack itemstack1 = null;
int j;
for (j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j)
{
ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j);
if (itemstack2 != null)
{
if (i == 0)
{
itemstack = itemstack2;
}
if (i == 1)
{
itemstack1 = itemstack2;
}
++i;
}
}
if (i == 2 && itemstack.itemID == itemstack1.itemID && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && Item.itemsList[itemstack.itemID].isRepairable())
{
Item item = Item.itemsList[itemstack.itemID];
int k = item.getMaxDamage() - itemstack.getItemDamageForDisplay();
int l = item.getMaxDamage() - itemstack1.getItemDamageForDisplay();
int i1 = k + l + item.getMaxDamage() * 5 / 100;
int j1 = item.getMaxDamage() - i1;
if (j1 < 0)
{
j1 = 0;
}
return new ItemStack(itemstack.itemID, 1, j1);
}
else
{
for (j = 0; j < this.recipes.size(); ++j)
{
IRecipe irecipe = (IRecipe)this.recipes.get(j);
if (irecipe.matches(par1InventoryCrafting, par2World))
{
return irecipe.getCraftingResult(par1InventoryCrafting);
}
}
return null;
}
}
/**
* returns the List<> of all recipes
*/
public List getRecipeList()
{
return this.recipes;
}
}
EDIT: GuiHandler (Seems like I forgot that.)
package heitage;
import heitagebenches.ContainerPrepTable;
import heitagebenches.GuiPrepTable;
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 tile_entity = world.getBlockTileEntity(x, y, z);
switch (ID)
{
//case 0: return new ContainerDryingRack(player.inventory, (TileEntityDryingRack)tile_entity);
case 1: return ID == 1 && world.getBlockId(x, y, z) == Main_Craft.PrepTable.blockID ? new ContainerPrepTable(player.inventory, world, x, y, z) : null;
}
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
switch (ID)
{
//case 0: return new GuiDryingRack(player.inventory, (TileEntityDryingRack) tile_entity);
case 1: return ID == 1 && world.getBlockId(x, y, z) == Main_Craft.PrepTable.blockID ? new GuiPrepTable(player.inventory, world, x, y, z) : null;
}
return null;
}
}
For those having trouble with their crafting manager not working.....
I would review my tutorial again. Please pay attention to how I am making the class files, especially the part where I "Delete" the imports and reimport them one at a time. The ones you are most likely missing are the ones in the GUI and container classes.... In the GUI you are importing the crafting manager as opposed to the custom one you have made and in the container you need to fix the can interact with method and point the block to your custom block.....This is most likely why your crafting manager is not working....
micro, it's been ages... I never see you on Skype. I imagine you are very busy, aren't you?
You have no idea.....I get maybe 4 to 6 hours a week now for coding. My new job has me working a lot and when I am not working I am either sleeping or with my son. I am finishing up some changes to my builder mod and hoping to have 0.7.0 by next week (the villager update). Then I want to get back to better crafting for a bit. I am actually off to bed now, just got my son on the bus for school and need to sleep for work tonight....I am still around to help out on the forums, I actually have more time for that than anything else coding wise...
For people who post here saying this wont work or that wont work I urge you to listen Mr microjunk when he states "look at the vanilla src code!"
I am new to modding Minecraft and using Java(worked with C++), and the point of being a Developer is to experiment with our code and spend those many bug fixing hours studying the documentation and other peoples code which they have been gracious to show us!
Thank you for the tutorials microjunk you have been a major help in understanding how Minecrafts "quirks" in java work!
I hope we can look forward to more!
Thanks...I like to see comments like this one. Most of the problems some seem to have with my tutorial is the imports being left in. But as you stated simply looking at the vanilla source and double checking their work against my guide, these issues wont happen....Thanks for the comment...
This may be a stupid question, but how would you convert the vanilla 3x3 crafting recipes to the custom ones? The vanilla recipes are only craftable in the top left 3x3 of my grid.
This may be a stupid question, but how would you convert the vanilla 3x3 crafting recipes to the custom ones? The vanilla recipes are only craftable in the top left 3x3 of my grid.
That is all explained on the main page...post number 2
That is all explained on the main page...post number 2
I'm probably missing something blatantly obvious, but it looks like that's just how to create NEW recipes. I made a new recipe for my grid, and it works fine, but I want to be able to craft the vanilla recipes in my custom grid as well, but they only work in the top left 3x3, and ignore the rest of the grid. Proof:
Is there something I have to do? Or am I just being an idiot again?
I'm probably missing something blatantly obvious, but it looks like that's just how to create NEW recipes. I made a new recipe for my grid, and it works fine, but I want to be able to craft the vanilla recipes in my custom grid as well, but they only work in the top left 3x3, and ignore the rest of the grid. Proof:
Is there something I have to do? Or am I just being an idiot again?
You are missing something...What I mean is in the container where you declare your grid size...this case looks like 4x4...also in the container I mention in the video about the multiplication of the grid size. Also you need a custom recipe sorter and shaped and shapeless classes as well...all explained in the video. then you can make your custom recipes in the crafting manager and all should work just fine.
You are missing something...What I mean is in the container where you declare your grid size...this case looks like 4x4...also in the container I mention in the video about the multiplication of the grid size. Also you need a custom recipe sorter and shaped and shapeless classes as well...all explained in the video. then you can make your custom recipes in the crafting manager and all should work just fine.
No, I have those. I also made a custom recipe using the 4x4, and it works exactly how I thought it would. The problem is that the vanilla recipes are hard coded to a maximum 3x3 grid. How do I make them work in a 4x4?
If your recipe classes are all correct using the same 4x4 shaped pattern, then I can only tell you you will have to remake all the vanilla recipes in your table...honestly though since you dont like to post code I am not really sure how to help with that one...try posting your crafting manager....and recipe classes.
If your recipe classes are all correct using the same 4x4 shaped pattern, then I can only tell you you will have to remake all the vanilla recipes in your table...honestly though since you dont like to post code I am not really sure how to help with that one...try posting your crafting manager....and recipe classes.
Yeah... sorry about the lack of code. Normally I would just stick all the code up there, but I'm part of a dev team right now, and I really don't want to get in trouble for posting source code to the mod. :/
I got vanilla shaped and shapeless, and ore dictionary shapeless to work, but I can't seem to get the old ore dictionary shaped recipes to work. Relevant code:
code]else if (recipe instanceof ShapedOreRecipe)
{
ShapedOreRecipe shapedOreRecipe = (ShapedOreRecipe)recipe;
AdvancedShapedOreRecipe advancedShapedOreRecipe = new AdvancedShapedOreRecipe(shapedOreRecipe, size.getHeight(), size.getWidth());
this.recipes.add(recipe);
}[/code]
[code]public AdvancedShapedOreRecipe(ShapedOreRecipe recipe, int craftingHeight, int craftingWidth)
{
output = recipe.getRecipeOutput();
System.out.println(output.getDisplayName() + "(" + output.itemID + ")");
Object[] temp = recipe.getInput();
System.out.println("Size = " + temp.length);
input = new Object[MAX_CRAFT_GRID_HEIGHT * MAX_CRAFT_GRID_WIDTH];
for (int i = 0; i < temp.length; i++)
{
input[i] = temp[i];
}
input = temp;
System.out.println("Size = " + input.length);
}[/code]
My first thought is, why are you using @suppresswarnings? There should be no warnings to suppress...
Find out how I generate....coolAlias...world structure generation and rotation tool...
Find out how I generate....coolAlias...world structure generation and rotation tool...
Find out how I generate....coolAlias...world structure generation and rotation tool...
Id start by going back to the first post and watching my videos for the 3x3 table. Then I would remove the @suppresswarnings from your code and try to figure out by watching my videos why you are getting those yellow lines. And then lastly, I will say it again, use the source code for the vanilla table and copy them over, just like in my video and all should work good. And if you are using items from your mod to craft, you need to make sure you are adding them correctly. This works flawlessly. I have made many tables and furnaces both using the code from in game to recreate them and just making the Necessary changes every time.
Find out how I generate....coolAlias...world structure generation and rotation tool...
I love your username and profile pic, eXistenZ was an awesome movie and rpg maker is a fun engine
Vanilla recipes show in the output slot but as soon as I add my own recipe to the table the output is blank,it does work but it just doesn't show.
Only my custom recipes have a blank output,the vanilla ones show the output as they should.
Here's my codes:
Main Class:
BlockPrepTable:
ContainerPrepTable:
GuiPrepTable (note: I use the vanilla gui,that's why the code looks like this):
SlotPrepTable:
RecipeSorterPrepTable:
CraftingManagerPrepTable:
EDIT: GuiHandler (Seems like I forgot that.)
Thanks man,totally agree!
I would review my tutorial again. Please pay attention to how I am making the class files, especially the part where I "Delete" the imports and reimport them one at a time. The ones you are most likely missing are the ones in the GUI and container classes.... In the GUI you are importing the crafting manager as opposed to the custom one you have made and in the container you need to fix the can interact with method and point the block to your custom block.....This is most likely why your crafting manager is not working....
Find out how I generate....coolAlias...world structure generation and rotation tool...
You have no idea.....I get maybe 4 to 6 hours a week now for coding. My new job has me working a lot and when I am not working I am either sleeping or with my son. I am finishing up some changes to my builder mod and hoping to have 0.7.0 by next week (the villager update). Then I want to get back to better crafting for a bit. I am actually off to bed now, just got my son on the bus for school and need to sleep for work tonight....I am still around to help out on the forums, I actually have more time for that than anything else coding wise...
Find out how I generate....coolAlias...world structure generation and rotation tool...
Thanks...I like to see comments like this one. Most of the problems some seem to have with my tutorial is the imports being left in. But as you stated simply looking at the vanilla source and double checking their work against my guide, these issues wont happen....Thanks for the comment...
Find out how I generate....coolAlias...world structure generation and rotation tool...
YouTube | Twitter | Patreon
-tlf
That is all explained on the main page...post number 2
Find out how I generate....coolAlias...world structure generation and rotation tool...
-tlf
You are missing something...What I mean is in the container where you declare your grid size...this case looks like 4x4...also in the container I mention in the video about the multiplication of the grid size. Also you need a custom recipe sorter and shaped and shapeless classes as well...all explained in the video. then you can make your custom recipes in the crafting manager and all should work just fine.
Find out how I generate....coolAlias...world structure generation and rotation tool...
-tlf
Find out how I generate....coolAlias...world structure generation and rotation tool...
I got vanilla shaped and shapeless, and ore dictionary shapeless to work, but I can't seem to get the old ore dictionary shaped recipes to work. Relevant code:
{
ShapedOreRecipe shapedOreRecipe = (ShapedOreRecipe)recipe;
AdvancedShapedOreRecipe advancedShapedOreRecipe = new AdvancedShapedOreRecipe(shapedOreRecipe, size.getHeight(), size.getWidth());
this.recipes.add(recipe);
}[/code]
Any idea why this is sticking to a 3x3?
-tlf