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 am trying to update some code that adds reach distance to my mod and i have been stuck for hours trying to fix this issue. I have fixed it with other items in the mod by swapping the DamageSource to this.damageSources() but for some reason that will not work for this. It tells me it can not resolve the method. any help would be appreciated thanks.

CODE:

if (result == null || !(result.getEntity() instanceof LivingEntity target)) return false;

double distanceToTargetSqr = entity.distanceToSqr(target);

boolean hitResult = (result != null ? target : null) != null;

if (hitResult) {

   if (entity instanceof Player) {

      if (reachSqr >= distanceToTargetSqr) {

          target.hurt(this.damageSources().playerAttack((Player) entity), getDamage());

}

}

}

 

//PROBLEM IS AT damageSources().playerAttack. (Also i know theres a way to insert code onto here but idk how to).

Posting random snippets of code out of context will likely just mean your is question ignored.

Especially if you are posting compiler errors, which is an indication you don't understand java.

 

Anwyay, the only places in the minecraft code that have a damageSources() method are Level and Entity.

It doesn't sound like you coding one of those? So obviously "this" won't work.

Maybe you want?

target.damageSources()

 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

Thanks it worked. Yeah i'm decently new to Java Im quite young but ive been trying to learn it for 3 years but obviously im no pro but im still currently learning it i just dont have the time currently to focus on it Thanks Anyway. Also This is my first post so I will take into account the snippet thing in the future

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.