Jump to content

Updating DamageSources(damageSources()) to 1.19.4 Not working


Tigidipops

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.