This error occurs because there is no variable called NBTTagCompound, just like you did before you should make a new one.
before you did: itemstack.stackTagCompound = new NBTTagCompound().
so you were creating a new NBTTagCompound, but now you just give it a NBTTagCompound without creating it. replacing 'NBTTagCompound' with 'new NBTTagCompound()' should fix it.
I don't completely understand that, but it worked!
In the crashlog it says that there's a NullPointerException on line 33 in your ItemBlockTorchLitCoke class.
I'm guessing this is the line:
if (compound.getInteger("tickCounter") == 20) {
can you confirm this for me?
If this is the case it means the itemStack doesn't have a tagCompound yet.
you can check in your onUpdate method if it already has a NBTTagCompound by using the hasTagCompound() method. If it doesn't have a tag compound you can assign a new one to the itemstack and add the tickCounter to that new NBTTagCompound.
Yep, that's line 33. Lolcroc said it never made a tagCompound because onCreate was never called. I'll use the check. Just for clarification, is the tagCompound basically saying it has NBT? like it's the root NBT thing or something? Or is is a specific NBT tag?
Also, When I add the method in the update method: The method hasTagCompound() is undefined for the type ItemBlockTorchLitCoke
Actually, I just had to add itemstack. to the front. Why though?
Just for clarification, is the tagCompound basically saying it has NBT? like it's the root NBT thing or something? Or is is a specific NBT tag?
You are right, itemstack.hasTagCompound() returns true if the itemstack has NBT data, if you want to check for a certain tag on that data you need to use
Right now I'm just checking if it has NBT at all, then if it doesn't add tickCounter. Should I also check for tickCounter specifically even if the first check (hasTagCompound) doesn't fail?
But right now, it works perfectly! Thanks a ton for everyones help!
I don't know if this is related to this thread, but it looks like I crash at line 127 (return (TileEntityTorchLitCoke) world.getTileEntity(x, y, z);) for some reason. It says I cast to something I don't cast to... I'm completely lost, because I don't really understand casting that well. Here is the:
Somehow the TileEntity at those coordinates is an instance of TileEntityTorchLit, but you're trying to cast it to TileEntityTorchLitCoke.
I'm not sure why it's an instance of TileEntityTorchLit, since your BlockTorchLitCoke class creates an instance of TileEntityTorchLitCoke in createNewTileEntity.
Is there a reason you have separate Block and TileEntity classes for coke torches? Couldn't you use the same classes for both types or at least put most of the logic in shared super classes?
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I don't know why it's making the wrong tileentity. Maybe it's a sort of "leftover" torch from when I made changes. I'll try removing it and placing a new one.
As for the two classes, I thought of that (super class) and I actually would like it, but I don't have any idea how. I know that it basically falls under the premise of "parenting," but I have not looked into it. Do you know any good tutorials?
EDIT: Actually, didn't I just use what your talking about to make the torches in the first place? I didn't copy all t logic over from torches, just made it extend or implement or something the vanilla torch. Is this what I have to do basically?
Inheritance is a basic concept of all object oriented languages, including Java. You really need to understand how this works if you want to make a mod.
You did extend the BlockTorch class to make your torches inherit the behaviour of vanilla torches.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I understand inheritance, just not how to use inheritance in Java specifically. I don't exactly know how I am learning Java... I guess just as I go I learn things about it. So if a made a main TileEntity class, and made both the other TileEntities inherit from it, they would inherit everything and I would override the max fuel and the blocks they turn into when they burn out, correct?
Put all common logic in the super class, then override any type-specific logic in the subclasses.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I don't completely understand that, but it worked!
So I probably shouldn't use a local variable... just edit the NBT directly? I crash with my current code. Or is the local variable not the problem?
UPDATE: Here is my code and the crash report:
http://pastebin.com/G5pMkBei
Would putting these events just in the class work, outside of any method?
In the crashlog it says that there's a NullPointerException on line 33 in your ItemBlockTorchLitCoke class.
I'm guessing this is the line:
if (compound.getInteger("tickCounter") == 20) {
can you confirm this for me?
If this is the case it means the itemStack doesn't have a tagCompound yet.
you can check in your onUpdate method if it already has a NBTTagCompound by using the hasTagCompound() method. If it doesn't have a tag compound you can assign a new one to the itemstack and add the tickCounter to that new NBTTagCompound.
and the Chunked pvp mod: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2128311-chunked-pvp#c2
Yep, that's line 33. Lolcroc said it never made a tagCompound because onCreate was never called. I'll use the check. Just for clarification, is the tagCompound basically saying it has NBT? like it's the root NBT thing or something? Or is is a specific NBT tag?
Also, When I add the method in the update method: The method hasTagCompound() is undefined for the type ItemBlockTorchLitCoke
Actually, I just had to add itemstack. to the front. Why though?
You are right, itemstack.hasTagCompound() returns true if the itemstack has NBT data, if you want to check for a certain tag on that data you need to use
NBTTagCompound.hasKey("Name of the tag")
and the Chunked pvp mod: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2128311-chunked-pvp#c2
Right now I'm just checking if it has NBT at all, then if it doesn't add tickCounter. Should I also check for tickCounter specifically even if the first check (hasTagCompound) doesn't fail?
But right now, it works perfectly! Thanks a ton for everyones help!
Checking if it has NBT at all should do.
If you assign new nbt you always write the tickCounter to it right?
You can always add a check just to make sure, but it shouldn't be needed.
and the Chunked pvp mod: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2128311-chunked-pvp#c2
NO. This isn't over until you LEARN JAVA.
I'm working on an open-source mod called Craft++. Check it out!
Um, I intend to. I have learned some Java from modding so far and intend to continue.
But for now, my problem is fixed. Now I just have to get the particles working...
I don't know if this is related to this thread, but it looks like I crash at line 127 (return (TileEntityTorchLitCoke) world.getTileEntity(x, y, z);) for some reason. It says I cast to something I don't cast to... I'm completely lost, because I don't really understand casting that well. Here is the:
crash: http://pastebin.com/DhjSdyhN
class: http://pastebin.com/4vr9srmr
Any ideas?
Somehow the TileEntity at those coordinates is an instance of TileEntityTorchLit, but you're trying to cast it to TileEntityTorchLitCoke.
I'm not sure why it's an instance of TileEntityTorchLit, since your BlockTorchLitCoke class creates an instance of TileEntityTorchLitCoke in createNewTileEntity.
Is there a reason you have separate Block and TileEntity classes for coke torches? Couldn't you use the same classes for both types or at least put most of the logic in shared super classes?
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I don't know why it's making the wrong tileentity. Maybe it's a sort of "leftover" torch from when I made changes. I'll try removing it and placing a new one.
As for the two classes, I thought of that (super class) and I actually would like it, but I don't have any idea how. I know that it basically falls under the premise of "parenting," but I have not looked into it. Do you know any good tutorials?
EDIT: Actually, didn't I just use what your talking about to make the torches in the first place? I didn't copy all t logic over from torches, just made it extend or implement or something the vanilla torch. Is this what I have to do basically?
Inheritance is a basic concept of all object oriented languages, including Java. You really need to understand how this works if you want to make a mod.
I didn't learn Java from tutorials so I'm not sure which ones are good, but you could try Vswe's Summer Courses or thenewboston's tutorials.
You did extend the BlockTorch class to make your torches inherit the behaviour of vanilla torches.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I understand inheritance, just not how to use inheritance in Java specifically. I don't exactly know how I am learning Java... I guess just as I go I learn things about it. So if a made a main TileEntity class, and made both the other TileEntities inherit from it, they would inherit everything and I would override the max fuel and the blocks they turn into when they burn out, correct?
Yes, that's correct.
Put all common logic in the super class, then override any type-specific logic in the subclasses.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.