That fixed it thanks. And is there any way to get a onCrafting like in a class that extends ICraftingHandler? I want to be able to give achievements for crafting certain things, which is done through onCrafting.
Rollback Post to RevisionRollBack
Legend of Zelda Mod(Minecraft 1.10.2!)[Updated September 10th 2016 to 4.0-pre2]
That fixed it thanks. And is there any way to get a onCrafting like in a class that extends ICraftingHandler? I want to be able to give achievements for crafting certain things, which is done through onCrafting.
One way is with a crafting handler, another is to look at the Irecipe class I think, where achievements are given when using the vanilla bench. Easy to duplicate, just look at how it is done there. Or like I said a crafting handler works good too...
I'm using 1.5.2 And i'm trying to add 2 GUI's in the Same Handler.(Don't ask why i'm using 1.5.2)
And i can't get it to Work.
The Second Block Always ends up Crashing my Game. But the first one Works.
If you want the Full Code let me know.
But here's my GuiHandler:
package JapangaCraft.SkyrimCraft;
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 GuiInputHandler 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 ContainerInputFurnace(player.inventory, (TileEntityInputFurnace) tile_entity);
case 1: return ID == 1 && world.getBlockId(x, y, z) == SkyrimCraft.forge.blockID ? new ContainerForge(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 GuiInputFurnace(player.inventory, (TileEntityInputFurnace) tile_entity);
case 1: return ID == 1 && world.getBlockId(x, y, z) == SkyrimCraft.forge.blockID ? new ContainerForge(player.inventory, world, x, y, z) : null;
}
return null;
}
}
Make sure that the onBlockActivated in both blocks have the correct GUI id...the block class you have there is 1, so I am assuming it is your table class, yes? So the other block class should have a 0. If it does, then I will need to borrow your FULL source so I can drop it in eclipse and check it from there (I hope that wont be a problem, just send the link in a PM. From the looks of the GUI handler all is correct. Dont worry I have made this mistake a few times myself.
I have a problem. I have got the GUI working for the most part, however when I right click on it it closes almost instantly. Also I'm not sure why but my GUI texture isn't loading and its using the default.
I have a problem. I have got the GUI working for the most part, however when I right click on it it closes almost instantly. Also I'm not sure why but my GUI texture isn't loading and its using the default.
This question was answered not even 4 posts above yours......
in the container...the can interact with method, look for block.workbench.blockID, or thats what it should be, you want to change that to your block.
This question was answered not even 4 posts above yours......
in the container...the can interact with method, look for block.workbench.blockID, or thats what it should be, you want to change that to your block.
Oh sorry, I must have missed that. Thanks for the great tutorial though. I can probably figure it out on my own but, do you know how to set the texture to your custom gui skin? I changed it in the GUI class but it didnt work.
One way is with a crafting handler, another is to look at the Irecipe class I think, where achievements are given when using the vanilla bench. Easy to duplicate, just look at how it is done there. Or like I said a crafting handler works good too...
Ah! the onCrafting method is in the slot class, I can just use that!
Rollback Post to RevisionRollBack
Legend of Zelda Mod(Minecraft 1.10.2!)[Updated September 10th 2016 to 4.0-pre2]
Where are you putting your recipe, in the crafting manager I assume. Look at the vanilla manager and see how the recipes are added there? make yours the same.....
Where are you putting your recipe, in the crafting manager I assume. Look at the vanilla manager and see how the recipes are added there? make yours the same.....
Heres my Crafting Manager Code:
package SoulsMod;
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;
public class GemTableCraftingManager
{
private static final GemTableCraftingManager instance = new GemTableCraftingManager();
private List recipes = new ArrayList();
public static final GemTableCraftingManager getInstance()
{
return instance;
}
private GemTableCraftingManager()
{
recipes = new ArrayList();
//Recipes
this.addRecipe(new ItemStack(SoulsMod.gemAmathystPerfect), new Object[]{"AAA", Character.valueOf('A'),SoulsMod.gemAmathystChipped});
Collections.sort(this.recipes, new GemTableRecipeSorter(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;
}
}
This is how my crafting manager looks, from my builder mod, so I know this works, plus I am using forge 789 still just have not updated forge...should be the same so long as this is 1.6.2, not much different at all from 1.5.2 really if at all...
public class BuilderCraftingManager
{
public static final int WILDCARD_VALUE = Short.MAX_VALUE;
/** The static instance of this class */
private static final BuilderCraftingManager instance = new BuilderCraftingManager();
/** A list of all the recipes added */
private List recipes = new ArrayList();
/**
* Returns the static instance of this class
*/
public static final BuilderCraftingManager getInstance()
{
return instance;
}
private BuilderCraftingManager()
{
recipes = new ArrayList();
this.func_92051_a(new ItemStack(Builder.netherEscape, 1), new Object[] {"ROOOR", "OOOOO", "OOROO", "OOOOO", "ROOOR", Character.valueOf('O'), Block.dirt, Character.valueOf('R'), Item.redstone});
//this.func_92051_a(new ItemStack(Builder.japan, 1), new Object[] {"PHNSP", "PCPCP", "CPCPC", "BBPBB", "PBTBP", Character.valueOf('P'), Block.planks, Character.valueOf('H'), new ItemStack(Builder.hammer, 1, WILDCARD_VALUE), Character.valueOf('S'), new ItemStack(Builder.handSaw, 1, WILDCARD_VALUE), Character.valueOf('N'), Builder.nail, Character.valueOf('C'), Block.cloth, Character.valueOf('B'), Block.stone, Character.valueOf('T'), Block.stairsCobblestone});
this.func_92051_a(new ItemStack(Builder.normalVillage, 1), new Object[] {"PHNSP", "PCPCP", "PCPCP", "PTPCP", "PCPFP", Character.valueOf('P'), Block.planks, Character.valueOf('H'), new ItemStack(Builder.hammer, 1, WILDCARD_VALUE), Character.valueOf('S'), new ItemStack(Builder.handSaw, 1, WILDCARD_VALUE), Character.valueOf('N'), Builder.nail, Character.valueOf('C'), Block.cobblestone, Character.valueOf('T'), Block.workbench, Character.valueOf('F'), Block.furnaceIdle});
//this.func_92051_a(new ItemStack(Builder.uniqueHomes, 1), new Object[] {"PHNSP", "PCPCP", "PDPDP", "APAPA", "PLPLP", Character.valueOf('P'), Block.planks, Character.valueOf('H'), new ItemStack(Builder.hammer, 1, WILDCARD_VALUE), Character.valueOf('S'), new ItemStack(Builder.handSaw, 1, WILDCARD_VALUE), Character.valueOf('N'), Builder.nail, Character.valueOf('C'), Block.cobblestone, Character.valueOf('D'), Block.sand, Character.valueOf('A'), Block.blockSnow, Character.valueOf('L'), Block.leaves});
//this.func_92051_a(new ItemStack(Builder.medieval, 1), new Object[] {"OHNSO", "PCPCP", "PCWCP", "PFGTP", "OEBEO", Character.valueOf('P'), new ItemStack(Block.wood, 1, 1), Character.valueOf('H'), new ItemStack(Builder.hammer, 1, WILDCARD_VALUE), Character.valueOf('S'), new ItemStack(Builder.handSaw, 1, WILDCARD_VALUE), Character.valueOf('N'), Builder.nail, Character.valueOf('C'), Block.stone, Character.valueOf('W'), Item.bucketWater, Character.valueOf('F'), Block.furnaceIdle, Character.valueOf('G'), Block.fence, Character.valueOf('T'), Block.chest, Character.valueOf('E'), Block.stairsWoodSpruce, Character.valueOf('B'), Block.stairsCobblestone, Character.valueOf('O'), new ItemStack(Block.cloth, 1, 1)});
//this.func_92051_a(new ItemStack(Builder.viking, 1), new Object[] {"FHNSC", " P ", " P P ", "PAPAP", "AAAAA", Character.valueOf('P'), Block.planks, Character.valueOf('H'), new ItemStack(Builder.hammer, 1, WILDCARD_VALUE), Character.valueOf('S'), new ItemStack(Builder.handSaw, 1, WILDCARD_VALUE), Character.valueOf('N'), Builder.nail, Character.valueOf('C'), Block.chest, Character.valueOf('F'), Block.furnaceIdle, Character.valueOf('A'), Block.cobblestone});
//this.func_92051_a(new ItemStack(Builder.roman, 1), new Object[] {"PHNSP", "XRZRX", "XOKOX", "CRWRT", "PAXFP", Character.valueOf('P'), Block.planks, Character.valueOf('H'), new ItemStack(Builder.hammer, 1, WILDCARD_VALUE), Character.valueOf('S'), new ItemStack(Builder.handSaw, 1, WILDCARD_VALUE), Character.valueOf('N'), Builder.nail, Character.valueOf('X'), Block.sandStone, Character.valueOf('R'), Block.stone, Character.valueOf('Z'), Block.stoneSingleSlab, Character.valueOf('O'), new ItemStack(Block.cloth, 1, 1), Character.valueOf('K'), Block.bookShelf, Character.valueOf('C'), Block.chest, Character.valueOf('W'), Item.bucketWater, Character.valueOf('T'), Block.workbench, Character.valueOf('F'), Block.furnaceIdle, Character.valueOf('A'), Block.anvil});
Collections.sort(this.recipes, new BuilderRecipeSorter(this));
System.out.println(this.recipes.size() + " recipes");
}
public BuilderShapedRecipes func_92051_a(ItemStack par1ItemStack, Object ... par2ArrayOfObj)
{
String var3 = "";
int var4 = 0;
int var5 = 0;
int var6 = 0;
if (par2ArrayOfObj[var4] instanceof String[])
{
String[] var7 = (String[])((String[])par2ArrayOfObj[var4++]);
for (int var8 = 0; var8 < var7.length; ++var8)
{
String var9 = var7[var8];
++var6;
var5 = var9.length();
var3 = var3 + var9;
}
}
else
{
while (par2ArrayOfObj[var4] instanceof String)
{
String var11 = (String)par2ArrayOfObj[var4++];
++var6;
var5 = var11.length();
var3 = var3 + var11;
}
}
HashMap var12;
for (var12 = new HashMap(); var4 < par2ArrayOfObj.length; var4 += 2)
{
Character var13 = (Character)par2ArrayOfObj[var4];
ItemStack var14 = null;
if (par2ArrayOfObj[var4 + 1] instanceof Item)
{
var14 = new ItemStack((Item)par2ArrayOfObj[var4 + 1]);
}
else if (par2ArrayOfObj[var4 + 1] instanceof Block)
{
var14 = new ItemStack((Block)par2ArrayOfObj[var4 + 1], 1, -1);
}
else if (par2ArrayOfObj[var4 + 1] instanceof ItemStack)
{
var14 = (ItemStack)par2ArrayOfObj[var4 + 1];
}
var12.put(var13, var14);
}
ItemStack[] var15 = new ItemStack[var5 * var6];
for (int var16 = 0; var16 < var5 * var6; ++var16)
{
char var10 = var3.charAt(var16);
if (var12.containsKey(Character.valueOf(var10)))
{
var15[var16] = ((ItemStack)var12.get(Character.valueOf(var10))).copy();
}
else
{
var15[var16] = null;
}
}
BuilderShapedRecipes var17 = new BuilderShapedRecipes(var5, var6, var15, par1ItemStack);
this.recipes.add(var17);
return var17;
}
public void addBuilderShapelessRecipe(ItemStack par1ItemStack, Object ... par2ArrayOfObj)
{
ArrayList var3 = new ArrayList();
Object[] var4 = par2ArrayOfObj;
int var5 = par2ArrayOfObj.length;
for (int var6 = 0; var6 < var5; ++var6)
{
Object var7 = var4[var6];
if (var7 instanceof ItemStack)
{
var3.add(((ItemStack)var7).copy());
}
else if (var7 instanceof Item)
{
var3.add(new ItemStack((Item)var7));
}
else
{
if (!(var7 instanceof Block))
{
throw new RuntimeException("Invalid shapeless recipy!");
}
var3.add(new ItemStack((Block)var7));
}
}
this.recipes.add(new BuilderShapelessRecipes(par1ItemStack, var3));
}
public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World)
{
int var3 = 0;
ItemStack var4 = null;
ItemStack var5 = null;
int var6;
for (var6 = 0; var6 < par1InventoryCrafting.getSizeInventory(); ++var6)
{
ItemStack var7 = par1InventoryCrafting.getStackInSlot(var6);
if (var7 != null)
{
if (var3 == 0)
{
var4 = var7;
}
if (var3 == 1)
{
var5 = var7;
}
++var3;
}
}
if (var3 == 2 && var4.itemID == var5.itemID && var4.stackSize == 1 && var5.stackSize == 1 && Item.itemsList[var4.itemID].isRepairable())
{
Item var11 = Item.itemsList[var4.itemID];
int var13 = var11.getMaxDamage() - var4.getItemDamageForDisplay();
int var8 = var11.getMaxDamage() - var5.getItemDamageForDisplay();
int var9 = var13 + var8 + var11.getMaxDamage() * 5 / 100;
int var10 = var11.getMaxDamage() - var9;
if (var10 < 0)
{
var10 = 0;
}
return new ItemStack(var4.itemID, 1, var10);
}
else
{
for (var6 = 0; var6 < this.recipes.size(); ++var6)
{
IRecipe var12 = (IRecipe)this.recipes.get(var6);
if (var12.matches(par1InventoryCrafting, par2World))
{
return var12.getCraftingResult(par1InventoryCrafting);
}
}
return null;
}
}
/**
* returns the List<> of all recipes
*/
public List getRecipeList()
{
return this.recipes;
}
}
Actually you are using this addRecipe, and it should be this
this.func_92051_a
Which is a big difference as I have tried that before and it didnt work...also look through my code closely and see if there are any other differences....
You may also try and copy mine above to notepad, removing all the imports and such and in yours in eclipse, delete everything from the imports down (making a copy in notepad of course) and copy mine over. Then change the error codes to match your mod....example for your blocks and items in the recipe and make the recipe sorter to yours and so on....also any thing you have that imports your crafting manager, like the mod class or what have you, delete the import from those classes and then make the new one and then re import the class...may seem redundant to do so, but it may help.
Actually you are using this addRecipe, and it should be this
this.func_92051_a
Which is a big difference as I have tried that before and it didnt work...also look through my code closely and see if there are any other differences....
You may also try and copy mine above to notepad, removing all the imports and such and in yours in eclipse, delete everything from the imports down (making a copy in notepad of course) and copy mine over. Then change the error codes to match your mod....example for your blocks and items in the recipe and make the recipe sorter to yours and so on....also any thing you have that imports your crafting manager, like the mod class or what have you, delete the import from those classes and then make the new one and then re import the class...may seem redundant to do so, but it may help.
Oh had no idea. What you said seemed pretty crazy. But if what you said first doesn't work then I will copy and do that thing.
Legend of Zelda Mod (Minecraft 1.10.2!)[Updated September 10th 2016 to 4.0-pre2]
Extra Achievements (Minecraft 1.9.4!)[Updated July 8th 2016 to 2.3.3]
One way is with a crafting handler, another is to look at the Irecipe class I think, where achievements are given when using the vanilla bench. Easy to duplicate, just look at how it is done there. Or like I said a crafting handler works good too...
Find out how I generate....coolAlias...world structure generation and rotation tool...
And i can't get it to Work.
The Second Block Always ends up Crashing my Game. But the first one Works.
If you want the Full Code let me know.
But here's my GuiHandler:
And my BlockForge:
Is there a Fix?
Find out how I generate....coolAlias...world structure generation and rotation tool...
This question was answered not even 4 posts above yours......
in the container...the can interact with method, look for block.workbench.blockID, or thats what it should be, you want to change that to your block.
Find out how I generate....coolAlias...world structure generation and rotation tool...
Oh sorry, I must have missed that. Thanks for the great tutorial though. I can probably figure it out on my own but, do you know how to set the texture to your custom gui skin? I changed it in the GUI class but it didnt work.
Find out how I generate....coolAlias...world structure generation and rotation tool...
Ah! the onCrafting method is in the slot class, I can just use that!
Legend of Zelda Mod (Minecraft 1.10.2!)[Updated September 10th 2016 to 4.0-pre2]
Extra Achievements (Minecraft 1.9.4!)[Updated July 8th 2016 to 2.3.3]
Find out how I generate....coolAlias...world structure generation and rotation tool...
I'd prefer not to release all of my code to the public so if you need to look at it could I PM it to you instead?
it should not look like this.....but this instead
or this
you can not out the " " closed like that or the recipe will become void
Find out how I generate....coolAlias...world structure generation and rotation tool...
Find out how I generate....coolAlias...world structure generation and rotation tool...
Heres my Crafting Manager Code:
Don't know why nothing it working.
Find out how I generate....coolAlias...world structure generation and rotation tool...
this.func_92051_a
Which is a big difference as I have tried that before and it didnt work...also look through my code closely and see if there are any other differences....
You may also try and copy mine above to notepad, removing all the imports and such and in yours in eclipse, delete everything from the imports down (making a copy in notepad of course) and copy mine over. Then change the error codes to match your mod....example for your blocks and items in the recipe and make the recipe sorter to yours and so on....also any thing you have that imports your crafting manager, like the mod class or what have you, delete the import from those classes and then make the new one and then re import the class...may seem redundant to do so, but it may help.
Find out how I generate....coolAlias...world structure generation and rotation tool...
Oh had no idea. What you said seemed pretty crazy. But if what you said first doesn't work then I will copy and do that thing.