Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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);
}


}

 

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.

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.

I actually didn't realize there was a method for that. Excuse my ignorance! :P

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.

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.

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.

Omg I actually did that. xD Yeah, Item not Block. :P

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.