Here, I actually just wrote this because I was interested in making this work. I got it to work when you hit a mob, not right click.
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
fireEffect(3, par2EntityLiving);
lightningEffect(par2EntityLiving);
par1ItemStack.damageItem(1, par3EntityLiving);
return true;
}
public void lightningEffect(EntityLiving par1EntityLiving)
{
double x = par1EntityLiving.posX;
double y = par1EntityLiving.posY;
double z = par1EntityLiving.posZ;
World world = par1EntityLiving.worldObj;
EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z);
lightning.setPosition(x, y + 1, z);
world.spawnEntityInWorld(lightning);
}
Don't worry about the fireEffect method, that's my own and does not play in with the lightning. Hope this helps and let me know if it works.
Thank you very much,
definitely helped me
I was messing around when I thought the same but shooting fireballs...
I tried for some time, looked at the dispenser properties ...
But couldn't get it working,
I see you have some experience so maybe you would tell me how to do it?
Or the best is if you just could teach me how to find out...
Look at how the EntityLightningBolt works and try and work out how to spawn it. And yeah, you did bring a 1 year dead topic back, I'd recommend trying not to do that in the future.
Rollback Post to RevisionRollBack
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
Nice to see you are still around....I credit you everytime I do something involving GUI handling....
Lol, thanks. I've always been around, just not as active as before, life issues come up every now and again. That and schooling has picked up quite a bit.
The code given previously should help. Just go through and work on fixing the errors. I'll give you a hint, you need to spawn the EntityLightningBolt at a set of coordinates. The coordinates are given to you through the method parameters (look at the entity you hit for the posX, posY and posZ).
I mean, i don't know where to write it so i can obtain a lighting sword.
A javascript document? a plugin? ...
Seriously....This is a help section, not a gimme the code section.....
First you should have some java knowledge before modding....even a little is better than none
then you should have setup eclipse and MCP and forge (or modloader depending upon you choice of mod API)
Next you need to create the sword class and the code that is posted here for the lightning sword goes there...
you should also be more clear as to what you are trying to do, create a mod using forge and show some code you have and we can help point you in the right direction, or tell us you are making a bukkit plugin....Also as it has been said this is an old thread, you should have started your own thread for this....
I want something to add to my server to make an HG kit with a lighting sword. Nothing more
You are going to have to create the whole mod then, many tutorials for this....other wise if you are an admin, you can just call the smite method I believe and the player and they will be struck by lightning....
You will still need to make it a mod then...Have you tried to make the mod at all? Do you have a mod started and not understand how to make the sword? for what you are looking for, from the sounds of it, you will need a mod as there is no way around it, and depending on how you make the mod, the clients shouldnt need the mod to play....
Talking Nothing About Code But You Can Install The Herobrine Mod And Sometimes Herobrine (When Summoned) Will Make A Shrine Go Inside Of It And Look For A Sword (It Might Take A Few Trys There Are 2 Perks) Then Take It And Hit A Mob It Will Strike Lightning
Considering both the server and the clients of your players will need to have Forge installed if you wish to implement this single weapon, it's probably not worth it unless you pick up some other mods as well. Either way, if you want me to copypaste the code already posted here in a mod and give you a download link, hit me up and provide me with a desired recipe for the sword and a possible icon.
public void lightningPower(EntityLiving par3)
{
double X = par3.posX;
double Y = par3.posY;
double Z = par3.posZ;
World world = par3.worldObj;
EntityLightningBolt lightning = new EntityLightningBolt(world, X, Y, Z);
if(par3 instanceof EntityPlayer)
{
lightning.setPosition(X, Y - 5, Z);
}
else
{
lightning.setPosition(X, Y, Z);
}
world.spawnEntityInWorld(lightning);
}
Incompatible conditional operand types EntityLiving and EntityPlayer
http://www.minecraftforum.net/topic/1142517-125more-tools-and-weapons/
try this:
Hello, Did you write this code yourself, or did you copy it from another file?
http://www.minecraftforum.net/topic/1142517-125more-tools-and-weapons/
it was taken from an outdated tutorial and then updated
Don't worry about the fireEffect method, that's my own and does not play in with the lightning. Hope this helps and let me know if it works.
Thank you very much,
definitely helped me
I was messing around when I thought the same but shooting fireballs...I tried for some time, looked at the dispenser properties ...
But couldn't get it working,
I see you have some experience so maybe you would tell me how to do it?
Or the best is if you just could teach me how to find out...
NVM
Ehm yeah, but how can you then do that u can do it "infinite" away, and on right click?NVM
Look at how the EntityLightningBolt works and try and work out how to spawn it. And yeah, you did bring a 1 year dead topic back, I'd recommend trying not to do that in the future.
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
My Github page.
The entire Minecraft shader development community now has its own Discord server! Feel free to join and chat with all the developers!
Nice to see you are still around....I credit you everytime I do something involving GUI handling....
Find out how I generate....coolAlias...world structure generation and rotation tool...
Lol, thanks. I've always been around, just not as active as before, life issues come up every now and again. That and schooling has picked up quite a bit.
The code given previously should help. Just go through and work on fixing the errors. I'll give you a hint, you need to spawn the EntityLightningBolt at a set of coordinates. The coordinates are given to you through the method parameters (look at the entity you hit for the posX, posY and posZ).
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
My Github page.
The entire Minecraft shader development community now has its own Discord server! Feel free to join and chat with all the developers!
Seriously....This is a help section, not a gimme the code section.....
First you should have some java knowledge before modding....even a little is better than none
then you should have setup eclipse and MCP and forge (or modloader depending upon you choice of mod API)
Next you need to create the sword class and the code that is posted here for the lightning sword goes there...
you should also be more clear as to what you are trying to do, create a mod using forge and show some code you have and we can help point you in the right direction, or tell us you are making a bukkit plugin....Also as it has been said this is an old thread, you should have started your own thread for this....
Find out how I generate....coolAlias...world structure generation and rotation tool...
You are going to have to create the whole mod then, many tutorials for this....other wise if you are an admin, you can just call the smite method I believe and the player and they will be struck by lightning....
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...
http://proseda.bplaced.net/herobrine/herobrinemod.html#.UpbiwsRmiFw Installed With FML
My mods: Archmagus, BetterBoneMeal, BetterVanilla, Brewing-API, NaturalArmors, and PluckableChickens!
public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase player)
{
target.worldObj.addWeatherEffect(new EntityLightningBolt(target.worldObj, target.posX, target.posY, target.posZ));
return true;
}
This should be written just before the last "}" of your sword code.
Orbixas
When I try this method I get this error:
Incompatible conditional operand types EntityLiving and EntityPlayer