Does anyone know a code that can make new items such as a wand to shoot lightning? I have tried many different things but it will not work. Please help!
First make your item a seperate class. Declare it and get the item set up.
You should have your normal item. . .
Now look around at items that place something. Something easy, like ItemDoor.
Look at how it places something.
Like you said, we wanna spawn the lightning. So put the placing method in and look through the weather code on how to make lightning. Then do the spawn lightning code.
I got a little confused... Where in the code of ItemDoor would I find how it places something? Sorry for the newbishenes I'm kinda new to this. Here's a diamond for helping
Don't use the code from ItemDoor, that spawns blocks, not entities...
Make your item similar to a bow in the fact that it uses par2World.spawnEntityInWorld() and go from there.
No offense to anyone but I am completely lost. Can anyone copy a raw code for me? Sorry for being such a noob, but I really want to get this done so I know how to do more complicated mods in the future. Anyone who can give me a raw code gets a diamond.
I don't even think you're supposed to paste just the code on the forums.
If you have Java knowledge (If you're modding Minecraft, you should, as Minecraft uses some pretty advanced Java and was overwhelming for me when I first started, despite the fact that I had already been learning Java for a year) you should be able to understand this:
You start by creating an item like this:
package net.minecraft.src;
public class ItemMyItem extends Item{
public ItemMyItem(int i){
//The i is your ID
super(i); //we call superclass constructor
maxStackSize = 1;
}
public boolean onItemRightClicked(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){
//parameter one is the current itemstack, par2world is the current world, par3EntityPlayer is the player using the item
//Now you can use a custom entity, and make it appear in the world using a method like this:
par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer); //Here we call spawnEntityInWorld method, and use a new snowball for our entity
return true;
}
}
This isn't going to get you exactly what you wanted, but it does give you a rough template that, if you have java knowledge, you can use to create some pretty cool stuff. Obviously you would need to look at the arrow and snowball code to figure out how to create custom entities, and then have this spawn custom entities and whatnot.
I'll try that NightHawk. Thanks for the code! I'll see how well it works and get back to you. I don't know a lot about Java, I just know the basics, and am eager to learn more things. I'd like to get a code that I can work from with my little knowledge of Java. Thanks!
I need more help understanding this! If there are any more kind souls out there, please help!
Anyone else? I hope I'm not asking for to big a favor from anybody. Also, if you want to check out a small showcase of my mod, check out this link. ---->
Basically you need to look over the snowball and/or arrow code to (EntityThrowable, EntitySnowball, EntityArrow) learn more about entity creation. Then use the code I gave you to make your wand item create the new Entity (you'll need to make this entity with a new class, etc) when the play right clicks. Then add your own code for other features. IDK how to make an actual thunderstorm lightning bolt appear, you'll have to find that out from someone else XD
Basically you need to look over the snowball and/or arrow code to (EntityThrowable, EntitySnowball, EntityArrow) learn more about entity creation. Then use the code I gave you to make your wand item create the new Entity (you'll need to make this entity with a new class, etc) when the play right clicks. Then add your own code for other features. IDK how to make an actual thunderstorm lightning bolt appear, you'll have to find that out from someone else XD
You might also want to check Spawner Egg code. They spawn entities too!
OK Nighthawk. Anyone willing to tell me how to spawn an actual lightning bolt?
Go to one of the classes for lightning, and one of them(or all of them) should have some name for the entity lightning. It would probably say 'EntityLightning' or something of the like but I'm not sure, check yourself.
This is a wand, not a bow. I hope that wasn't confusing, and if any part of the code is for a bow, please tell me. This change does not do anything for me.
You should have your normal item. . .
Now look around at items that place something. Something easy, like ItemDoor.
Look at how it places something.
Like you said, we wanna spawn the lightning. So put the placing method in and look through the weather code on how to make lightning. Then do the spawn lightning code.
Make your item similar to a bow in the fact that it uses par2World.spawnEntityInWorld() and go from there.
If you have Java knowledge (If you're modding Minecraft, you should, as Minecraft uses some pretty advanced Java and was overwhelming for me when I first started, despite the fact that I had already been learning Java for a year) you should be able to understand this:
You start by creating an item like this:
This isn't going to get you exactly what you wanted, but it does give you a rough template that, if you have java knowledge, you can use to create some pretty cool stuff. Obviously you would need to look at the arrow and snowball code to figure out how to create custom entities, and then have this spawn custom entities and whatnot.
Good luck with your modding!
I need more help understanding this! If there are any more kind souls out there, please help!
You might also want to check Spawner Egg code. They spawn entities too!
Go to one of the classes for lightning, and one of them(or all of them) should have some name for the entity lightning. It would probably say 'EntityLightning' or something of the like but I'm not sure, check yourself.
And I don't know what's wrong, because it won't do anything new to the wand. Please help!