is this modloader compatible? because it doesn't look like it is :0
Lol, in fact it is ModLoader compatible, all you need to do is register your item with ModLoader instead of the Item.java, everything else will not affect ModLoader at all because we are making new classes and not editing anything.
src\minecraft\net\minecraft\src\ItemBackpack.java:12: illegal start of expressio
n
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: not a statement
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
6 errors
==================
> Done in 6.58 seconds
> Recompiling server...
!! Can not find server sources !!
Press any key to continue . . .
src\minecraft\net\minecraft\src\ItemBackpack.java:12: illegal start of expressio
n
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: not a statement
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
6 errors
==================
> Done in 6.58 seconds
> Recompiling server...
!! Can not find server sources !!
Press any key to continue . . .
you never ended your constructor, add another } after inv=new HashMap<ItemStack, InventoryBackpack>();
package net.minecraft.src;
public class ItemBackpack extends Item{
private HashMap<ItemStack, InventoryBackpack> inv;
protected ItemBackpack(int ID) {
super(ID);
maxStackSize=1;
inv = new HashMap<ItemStack, InventoryBackpack>();
}
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityplayer)
{
entityplayer.displayGUIChest(inv.get(itemstack));
return itemstack;
}
}
Thanks for that but now i get these 2 errors
== ERRORS FOUND ==
src\minecraft\net\minecraft\src\ItemBackpack.java:5: cannot find symbol
symbol : class HashMap
location: class net.minecraft.src.ItemBackpack
private HashMap<ItemStack, InventoryBackpack> inv;
^
src\minecraft\net\minecraft\src\ItemBackpack.java:10: cannot find symbol
symbol : class HashMap
location: class net.minecraft.src.ItemBackpack
inv = new HashMap<ItemStack, InventoryBackpack>();
^
you have to import java.util.HashMap. I was thinking that the people who look at these tutorials would at least know enough about java to be able to import stuff. I guess I'll add the line.
you have to import java.until.HashMap. I was thinking that the people who look at these tutorials would at least know enough about java to be able to import stuff. I guess I'll add the line.
I still get the same error, i put it right under the package net.minecraft.src; and i get this error aswell as the other 2
== ERRORS FOUND ==
src\minecraft\net\minecraft\src\ItemBackpack.java:3: package java.until does not
exist
import java.until.HashMap;
^
So I mostly got the code working. I say mostly because the when I use the item in-game, nothing happens. No GUI. I have tried different ways to activate the item (onUseItem onRightClick on or two more, even tried making it an if statement) nothing really seems to work. I have no errors on recompile. Heres the code
strange bug, even though an item stack is passed into the inventories and stuff when you change it's slot or put it in a chest, etc... however for some reason if you move it at all it erases any items in it.
can you make a tutorial for custom gui? like GUI that doesnt look like chest GUI nor furnace, nor Craftbench gui. You can make that kind of gui yourself(that's why i ment "custom")
So I mostly got the code working. I say mostly because the when I use the item in-game, nothing happens. No GUI. I have tried different ways to activate the item (onUseItem onRightClick on or two more, even tried making it an if statement) nothing really seems to work. I have no errors on recompile. Heres the code
hmm, someone else said they got it to work, so I would not know why it will not.
Yeah i get the same thing, you cant right click it or anything to open it, is it missing a code so it can be right clicked? or make it a button command?
ok, someone was reporting issues with the onItemRightClick not working, so I changed it to onItemUse, not onItemUse is not working. I tried swiching back to onItemRightClick and all of a sudden it worked. so I do not know...
Thank you very much for posting that tutorial! But I have found found a bug. If you put your backpack into the backpack inventory space, well... the backpack is gone forever. Other than that, thank you!
Also if you even move the backpack or put it in a chest or even pick it up and put it back in the same spot it erases all the inventory. I'm trying to find out why. And the put the backpack in the backpack is a bit obvious that that bug will happen...
Also if you even move the backpack or put it in a chest or even pick it up and put it back in the same spot it erases all the inventory. I'm trying to find out why. And the put the backpack in the backpack is a bit obvious that that bug will happen...
If this helps, ive been told that with a chest, you cant move them with pistons as this stores all the items inside this one block and you cant make chests portable, but it could be the same with backpacks as it is staying in one spot and shouldnt be moved
yeah, it's strange, because when the methods get and set an item in the inventory it's passing the ItemStack instance, if that's the case then if an ItemStack was passed through the getItemInIndew and then was Set somewhere else, it would still be the same instance of ItemStack, it would still be the same and therefore I do not get why the inventory clears when you do anything to it.
Request time! Your tutorials are great and I was wondering if you could do one for a new workbench with a 3x4 (or other size) crafting grid? This workbench would allow you to make other items. If you could do this I would be INCREDIBLY happy!
Rollback Post to RevisionRollBack
Check out my minecraft tools, mods, or maybe my website! I've got tons of applications (both minecraft related and not) which some of you may find useful. Thanks!
Update:
2011-07-14 21:41 - commands.recompile - ERROR - javac.exe -g -verbose -classpath "lib/;lib/*;jars/bin/minecraft.jar;jars/bin/jinput.jar;jars/bin/lwjgl.jar;jars/bin/lwjgl_util.jar" -sourcepath src/minecraft -d bin/minecraft src/minecraft\net\minecraft\client\*.java src/minecraft\net\minecraft\isom\*.java src/minecraft\net\minecraft\src\*.java conf/patches/*.java failed.
2011-07-14 21:41 - commands.recompile - ERROR - Return code : 1
2011-07-14 21:41 - commands.recompile - ERROR -
2011-07-14 21:41 - commands.recompile - ERROR - == ERRORS FOUND ==
2011-07-14 21:41 - commands.recompile - ERROR -
2011-07-14 21:41 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:10: ';' expected
2011-07-14 21:41 - commands.recompile - ERROR - inv = HashMap <ItemStack, InventoryBackpack>;
2011-07-14 21:41 - commands.recompile - ERROR - ^
2011-07-14 21:41 - commands.recompile - ERROR -
2011-07-14 21:41 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:10: illegal start of expression
2011-07-14 21:41 - commands.recompile - ERROR - inv = HashMap <ItemStack, InventoryBackpack>;
2011-07-14 21:41 - commands.recompile - ERROR - ^
2011-07-14 21:41 - commands.recompile - ERROR -
2011-07-14 21:41 - commands.recompile - ERROR - src\minecraft\net\minecraft\src\ItemBackpack.java:10: not a statement
2011-07-14 21:41 - commands.recompile - ERROR - inv = HashMap <ItemStack, InventoryBackpack>;
2011-07-14 21:41 - commands.recompile - ERROR - ^
2011-07-14 21:41 - commands.recompile - ERROR -
2011-07-14 21:41 - commands.recompile - ERROR - 3 errors
2011-07-14 21:41 - commands.recompile - ERROR - ==================
2011-07-14 21:41 - commands.recompile - ERROR -
ItemBackpack
From my understanding, two of those errors usually point to a semi-colon or curly brace out of place, but that looks good to my eye.
Am I missing something obvious?
I made this map! Please check it out! It's a really awesome map that took me over a year to make! :3
first off don't be sorry for asking for support. If i did not expect people to reply with questions or need help I would not have posted this.
yes, when setting a hashmap you need to use new HashMap<Param1, Param2>() so:
Lol, in fact it is ModLoader compatible, all you need to do is register your item with ModLoader instead of the Item.java, everything else will not affect ModLoader at all because we are making new classes and not editing anything.
Error:
src\minecraft\net\minecraft\src\ItemBackpack.java:12: illegal start of expressio
n
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: not a statement
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
src\minecraft\net\minecraft\src\ItemBackpack.java:12: ';' expected
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityp
layer)
^
6 errors
==================
> Done in 6.58 seconds
> Recompiling server...
!! Can not find server sources !!
Press any key to continue . . .
ItemBackpack.java
public class ItemBackpack extends Item{
private HashMap<ItemStack, InventoryBackpack> inv;
protected ItemBackpack(int ID) {
super(ID);
maxStackSize=1;
inv = new HashMap<ItemStack, InventoryBackpack>();
public ItemStack onItemUse(ItemStack itemstack, World world,EntityPlayer entityplayer)
{
entityplayer.displayGUIChest(inv.get(itemstack));
return itemstack;
}
}
}
InventoryBackpack.java
public class InventoryBackpack implements IInventory
{
public InventoryBackpack()
{
packContents = new ItemStack[36];
}
public int getSizeInventory()
{
return 27;
}
public boolean canInteractWith(EntityPlayer entityplayer)
{
return !entityplayer.isDead;
}
public void onInventoryChanged()
{
}
public ItemStack getStackInSlot(int i)
{
return packContents[i];
}
public ItemStack decrStackSize(int i, int j)
{
if(packContents[i] != null)
{
if(packContents[i].stackSize <= j)
{
ItemStack itemstack = packContents[i];
packContents[i] = null;
onInventoryChanged();
return itemstack;
}
ItemStack itemstack1 = packContents[i].splitStack(j);
if(packContents[i].stackSize == 0)
{
packContents[i] = null;
}
onInventoryChanged();
return itemstack1;
} else
{
return null;
}
}
public void setInventorySlotContents(int i, ItemStack itemstack)
{
packContents[i] = itemstack;
if(itemstack != null && itemstack.stackSize > getInventoryStackLimit())
{
itemstack.stackSize = getInventoryStackLimit();
}
onInventoryChanged();
}
public String getInvName()
{
return "Backpack";
}
public void readFromNBT(NBTTagCompound nbttagcompound)
{
NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
packContents = new ItemStack[getSizeInventory()];
for(int i = 0; i < nbttaglist.tagCount(); i++)
{
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
int j = nbttagcompound1.getByte("Slot") & 0xff;
if(j >= 0 && j < packContents.length)
{
packContents[j] = new ItemStack(nbttagcompound1);
}
}
}
public void writeToNBT(NBTTagCompound nbttagcompound)
{
NBTTagList nbttaglist = new NBTTagList();
for(int i = 0; i < packContents.length; i++)
{
if(packContents[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)i);
packContents[i].writeToNBT(nbttagcompound1);
nbttaglist.setTag(nbttagcompound1);
}
}
nbttagcompound.setTag("Items", nbttaglist);
}
public int getInventoryStackLimit()
{
return 64;
}
private ItemStack packContents[];
}
you never ended your constructor, add another } after inv=new HashMap<ItemStack, InventoryBackpack>();
Thanks for that but now i get these 2 errors
src\minecraft\net\minecraft\src\ItemBackpack.java:5: cannot find symbol
symbol : class HashMap
location: class net.minecraft.src.ItemBackpack
private HashMap<ItemStack, InventoryBackpack> inv;
^
src\minecraft\net\minecraft\src\ItemBackpack.java:10: cannot find symbol
symbol : class HashMap
location: class net.minecraft.src.ItemBackpack
inv = new HashMap<ItemStack, InventoryBackpack>();
^
2 errors
==================
> Done in 20.23 seconds
> Recompiling server...
I still get the same error, i put it right under the package net.minecraft.src; and i get this error aswell as the other 2
== ERRORS FOUND ==
src\minecraft\net\minecraft\src\ItemBackpack.java:3: package java.until does not
exist
import java.until.HashMap;
^
ItemBackpack
package net.minecraft.src;
import java.util.HashMap;
public class ItemBackpack extends Item{
private HashMap<ItemStack, InventoryBackpack> inv;
protected ItemBackpack(int ID) {
super(ID);
maxStackSize=1;
inv = new HashMap <ItemStack, InventoryBackpack>();
}
public ItemStack onItemUse(ItemStack itemstack, World world, EntityPlayer entityplayer){
if(!inv.containsKey(itemstack)){
inv.put(itemstack, new InventoryBackpack());
}
entityplayer.displayGUIChest(inv.get(itemstack));
return itemstack;
}
}
InventoryBackpack
package net.minecraft.src;
public class InventoryBackpack implements IInventory
{
public InventoryBackpack()
{
packContents = new ItemStack[36];
}
public int getSizeInventory()
{
return 27;
}
public boolean canInteractWith(EntityPlayer entityplayer)
{
return entityplayer.isDead;
}
public void onInventoryChanged()
{
}
public ItemStack getStackInSlot(int i)
{
return packContents[i];
}
public ItemStack decrStackSize(int i, int j)
{
if(packContents[i] != null)
{
if(packContents[i].stackSize <= j)
{
ItemStack itemstack = packContents[i];
packContents[i] = null;
onInventoryChanged();
return itemstack;
}
ItemStack itemstack1 = packContents[i].splitStack(j);
if(packContents[i].stackSize == 0)
{
packContents[i] = null;
}
onInventoryChanged();
return itemstack1;
} else
{
return null;
}
}
public void setInventorySlotContents(int i, ItemStack itemstack)
{
packContents[i] = itemstack;
if(itemstack != null && itemstack.stackSize > getInventoryStackLimit())
{
itemstack.stackSize = getInventoryStackLimit();
}
onInventoryChanged();
}
public String getInvName()
{
return "Backpack";
}
public void readFromNBT(NBTTagCompound nbttagcompound)
{
NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
packContents = new ItemStack[getSizeInventory()];
for(int i = 0; i < nbttaglist.tagCount(); i++)
{
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
int j = nbttagcompound1.getByte("Slot") & 0xff;
if(j >= 0 && j < packContents.length)
{
packContents[j] = new ItemStack(nbttagcompound1);
}
}
}
public void writeToNBT(NBTTagCompound nbttagcompound)
{
NBTTagList nbttaglist = new NBTTagList();
for(int i = 0; i < packContents.length; i++)
{
if(packContents[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)i);
packContents[i].writeToNBT(nbttagcompound1);
nbttaglist.setTag(nbttagcompound1);
}
}
nbttagcompound.setTag("Items", nbttaglist);
}
public int getInventoryStackLimit()
{
return 64;
}
private ItemStack packContents[];
}
Yeah, I've been playing with it for days and I'm stumped.
Yeah i get the same thing, you cant right click it or anything to open it, is it missing a code so it can be right clicked? or make it a button command?
Also if you even move the backpack or put it in a chest or even pick it up and put it back in the same spot it erases all the inventory. I'm trying to find out why. And the put the backpack in the backpack is a bit obvious that that bug will happen...
If this helps, ive been told that with a chest, you cant move them with pistons as this stores all the items inside this one block and you cant make chests portable, but it could be the same with backpacks as it is staying in one spot and shouldnt be moved