Jump to content

I'm really struggling to make a lightning sword


CyberRocky

Recommended Posts

I'm trying to make it so lightning strikes the mob I hit with the sword. I've tried every code I could find online and all I get is errors I can't fix or it simply doesn't work.

 

I'm using Eclipse and 1.7.10 version of Forge. The coding I have so far for the sword without the lightning looks like this:

 

package cyberrocky.lsm.item;

import net.minecraft.item.Item;
import net.minecraft.item.ItemSword;

public class ItemLightningSword extends ItemSword {

public ItemLightningSword(ToolMaterial material) {
	super(material);
}


}

 

Link to comment
Share on other sites

Well first, you most likely should use an event like "LivingHurtEvent" then, check if it is your sword and, if so: grab the entity being hit and it's position then spawn the lightning.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

What? No... You don't need events for that. Events are to edit vanilla/other mod's behaviour.

 

In your sword class override #hitEntity, get target's position, spawn new lightning entity in given position.

 

Pretty much what above is said.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

We're not here to code it for you.

 

Read what forum description says. It's forum that will provide help woth forge (which I did), not Java directly.

 

My best advice (many will agree) - learn Java (actually take some course).

 

If you post what you've tried I could go from there and provide more explanations.

 

What to look for (google)

- How to spawn Entity in world.

- How is lightning spawned (I'd look in vanilla code)

 

Rest is REALLY SIMPLE - you just need to know minimum of Java.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

He is right ^ All I can say is, check the Block.java class for hitEntity and override it. Then do the necessary checks (like for server and such) and spawn the lightning if they are met.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.