#Messing with DamageTypes

206 messages · Page 1 of 1 (latest)

random crypt
#

Should I look more into the "onTargetDamaged" method of DamageEnchantment, or should I look into "getAttackDamage" when trying to change the DamageType of the attack?
I understand I may also be looking into the wrong areas, any help would be greatly appreciated!

tacit eagle
#

See the attack method in PlayerEntity

random crypt
#

I've been looking around the attack method in PlayerEntity for a while now, but I do not see where it is declaring the damageType
I will do some searching around other classes to see if I can find specifically where it is declared

random crypt
#

Is that not just a boolean that checks if the damage is originating from the attacking entity?

tacit eagle
#

All the boolean is there for is to check if the damage actually succeeded

random crypt
#

Oh, alright then

#

So to recap, PlayerEntityMixin with an if checking for the enchantment, then target.damage(this.getDamageSources(DamageTypeClass.DAMAGE_TYPE), damage_float);

#

Okay, I have begun to see this task as a bit silly and not entirely sensible
However I have a new goal that 1) may be more attainable, and 2) may be able to be done in just the enchantment class

#

What about instead of changing the entire damage type of the weapon, I add extra damage (of a different damage type) on top of the regular attack damage
Say a diamond sword with the Enchantment FlameBound did the regular 7 playerAttack damage but also did 3 flameMagic damage on top of it?

tacit eagle
#

Just modifyarg the damage call

random crypt
#

Alright

#

Just to bring up what I said a few minutes ago, how feasible would it be to add more damage onto a weapon of a different type?

tacit eagle
#

Probably modify the damage_float and subtract EnchantmentHelper.getattackdamage or whatever from it

#

Then add a new damage call and make the damage EnchantmentHelper.getattackdamage

random crypt
#

Alright, I'll get both working (hopefully) and see which one I prefer
And as always, thank you for helping

random crypt
# tacit eagle Probably modify the damage_float and subtract EnchantmentHelper.getattackdamage ...

I really hate to ping, but I still need some help. I have been unable to get the original plan working (changing the damage type when striking with the enchantment), but I would much rather divert my time to working on the new plan (adding extra damage of a new damage type). I hate to say this, but your earlier message (the one I am replying to) confuses me a bit. Could you explain it a bit differently for me, please?

random crypt
#

Whenever you're back, this is what I've got so far and it does not work as intended

#

Since it looks like I'm not sleeping tonight I will keep at it

random crypt
#

Decided to make some attributes revolving around the damage types, might make things a bit easier as well as a bit more satisfying with the interface

random crypt
#

I've gotten some more done and it does something?

#

I know it did something as before I fixed an error it would crash the game when hitting a mob (it no longer crashes)

tacit eagle
# random crypt I really hate to ping, but I still need some help. I have been unable to get the...

Plan 1:

@ModifyExpressionValue(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/damage/DamageSources;playerAttack(Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/entity/damage/DamageSource;"))
    private DamageSource weDoSomeChanging(DamageSource original){
        if (EnchantmentHelper.getLevel(someEnchantment, yourStack) > 0) {
            return this.getWorld().getDamageSources().magic(); // or something
        }
        return original;
    }

What I did here is modify the player attack to another damage source when a certain condition is true

tacit eagle
#

And you would probably need to reset the iframes before you applied the second damage

random crypt
#

So far my plan now is to add an attribute, which has been done, and then apply the attribute to the item

#

Messed around with inventoryTick for a bit before I passed out

#

Also with attack

#

Aaaand I broke something, reading the crash log hasn't helped much but I wonder if it is because I used @Inject, rather than @ModifyExpressionValue as you have taught me

tacit eagle
#

Because you aren't going to do anything with the return value

random crypt
#

Oh?

tacit eagle
tacit eagle
#

But you'll have to reset the iframes afterward or else the regular damage isn't going to be applied correctly

random crypt
#

Ohh, I suppose I was just trying to mimic the vanilla target.damage boolean

tacit eagle
#

Yeah but vanilla actually does checks with that boolean, you don't which means you don't need that variable

random crypt
random crypt
#

I've put the damage type in the vanilla tag bypasses_cooldown.json, but it has not made the damage pass through iframes

tacit eagle
random crypt
#

Oh, hm

tacit eagle
#

The easy fix for that is to reset the regen time and lastDamageTaken after you do the damage call

#

but that might lead to unintended consequences

random crypt
#

Alright, can I do that within the WcmPlayerEntityMixin class or would I require a new class?

#

Oh? What would those unintended consequences be?

tacit eagle
tacit eagle
random crypt
#

Oh lastDamageTaken is a method in the PlayerEntity class

#

Erm

tacit eagle
random crypt
#

Oh alright

tacit eagle
random crypt
#

Yeah, it was the inital idea, and I thank you for getting it to function, but I came to the understanding that changing the entire damage type was a bit silly
If you were hit with a sword with an enchantment that changed the damage type to a fire damage type, but you were immune to fire, don't you think you'd still be hurt by the very physical sword?

random crypt
tacit eagle
#

So therefore attacks of the sword would bypass all iframes

random crypt
#

Ah, alright

#

Is there any other method you can think of? Or is this the best option

tacit eagle
#

No idea

#

Someone else could probably come up with a better idea

random crypt
#

Until then I suppose I will go for your idea, in the end it shouldn't be the biggest deal? (especially if I don't tell anyone about it c;)
And even if people find out they won't be doing insane amounts of damage

#

All this hassle has been over at most 3.5 extra damage

#

Wait, should I utilize the damage method or the onDamaged method in the LivingEntity class?

#

I suppose damage would make more sense

random crypt
#

I got the iframe reset working! Buuut it isn't applying the damage, but I am certain I will be able to figure out why

#

I suppose I do not really need the attributes anymore, which is unfortunate as I thought it would be cool to have them. But if they are unneeded then they are unneeded

random crypt
#

Alright, now it is only applying the damage I add on to the weapon through the enchantment

#

Hm, changed some stuff around and now it deals one damage or the other

#

If I spam, magic damage, if I don't, regular damage

#

But if I attack something that is immune to the IS_FIRE damage type tag, then it reverts to the regular damage

tacit eagle
#

Can I see your mixin?

random crypt
#

But yeah, which mixin do you want to see?

#

PlayerEntityMixin is supposed to do the extra damage, and LivingEntityMixin is supposed to remove the iframes

#

modifyAttack and modifyDamage methods are shown

tacit eagle
#

You're checking if the main hand stack of the thing sustaining the damage has the enchantment

#

It should be if the main hand stack of the thing doing the damage has the enchantment

#

Additionally, you could just do all the iframe logic in the player mixin

random crypt
#

Yeah that makes a lot of sense now

#

Is this the appropriate way to great a variable checking for an attacker?
LivingEntity attacker = (LivingEntity) (Object) this;

#

I assume not because of this

tacit eagle
#

If you're putting it in the PlayerEntityMixin, just make the class abstract and have it extend LivingEntity

#

If you're trying to put it in the LivingEntityMixin, why are you trying to set the attacker as the one receiving the damage?

random crypt
#

I was putting it in PlayerEntityMixin, sorry for the confusion

random crypt
#

Just double checking

random crypt
#

Here's to hoping this works

#

Acts just like before

tacit eagle
random crypt
#

Oh snap

#

Lemme reread what you've said so far

#

Wait, what do you mean then?

tacit eagle
#

After calling target.damage in the first handler method, you should also reset the target's iframes by setting their lastDamageTaken to 0

random crypt
#

Oh

#

So just this?

#

I will give it a test

#

It appears I am still misinterpreting your words

random crypt
#

I feel as though something obvious is missing again, similar to how my LivingEntityMixin wasn't registered with the other mixins all that time ago

random crypt
#

@ me whenever you're free and still wanna help me out with this! I'm gonna take a break as I have been running in circles all day so far

random crypt
#

I did some more messing around, and I can return to the @Inject if I need to but so far this version does not yet afflict the custom damage type at all, even when spamming

random crypt
#

Okay

#

That's it, I think it may be time to go back to square one.

tacit eagle
random crypt
#

Oh hello

tacit eagle
#

It would be target.lastDamageTaken

random crypt
#

Oh?

#

OH

tacit eagle
#

You seem to be confusing the attacker and the target

tacit eagle
random crypt
# random crypt

Should I then ignore this and return to the @Inject version?

#

Alright, I will return to that iteration and with the fix will see if it works

tacit eagle
#

Sorry, I was busy for a little

random crypt
#

You are all alright, do not worry!

#

This code however

#

Is not alright

#

@tacit eagle because target is not working, should with use the CallbackInfo?

#

Apologies for pinging, again

#

I am going to go on a walk to clear my head, and maybe grab an icecream.
I will be availiable for discussion the entire time but will be unable to write code

tacit eagle
#
  1. You don't need to double cast to playerentity because all the methods you call will work with livingentity
random crypt
#

Oh, thank you

tacit eagle
#
  1. define "target is not working"
random crypt
#

The cause should be because it is an Entity variable, and not a Living/Player Entity, that is what I remember the issue being but I can check again when I'm home

random crypt
#

Alright, I have returend home

#

The symbol lasDamageTaken cannot be resolved at target.lastDamageTaken

tacit eagle
#

!!accessor

knotty pondBOT
#

io/github/mymod/mixin/MyClassAccess

@Mixin(MyClass.class)
public interface MyClassAccess {
  @Invoker void callAccess();
  @Accessor int getMyField();
}

to use it

public class Container {
  public void slapHaykam(MyClass instance) {
     ((MyClassAccess)instance).callAccess();
  }
}
random crypt
#

Alright, a new interface and a new Container class?

tacit eagle
#

You'll also have to set timeUntilRegen of the target to some number greater than 10

random crypt
#

Alrighty

tacit eagle
#

Just make a new interface first

random crypt
#

Ohhh! Okay
Is there a command to a wiki link for that?

#

!!interface

knotty pondBOT
#

@random crypt: Unknown tag, use !tag to see all available tags

random crypt
#

Hm

tacit eagle
#

They have some fundamental differences with classes, so I suggest you look them up

random crypt
#

Thank you, I will keep a note of interfaces in case I run into them

tacit eagle
random crypt
#

Alright

random crypt
#

Alright

#

For the @Accessor setLastDamageTaken, do I require an instance? Or would you rather me access timeUntilregen

#

I assumed lastDamageTaken at first, but you did mention timeUntilRegen a bit earlier, which is why I wish to ask before continuing forward

#

I would like to first extend my apologies for this frustrating adventure, it has been a couple days since we first started and I know I am not the most knowledgeable on Java

#

Wait I should be using @Invoke oh my goodness

tacit eagle
#

@random crypt Show your accessor

random crypt
#

I am lost it seems

tacit eagle
#

That's correct

random crypt
#

Oh yay

#

I did something right :D
Anyways time to show something I'm doing wrong

#

((WcmLivingEntityAccess) ());
That is as far as I've gotten to utilizing it

tacit eagle
#

Just cast the target to the accessor

random crypt
#

Hm

#

target.setLastDamageTaken
?

#

That is very much so not what I am looking for is it

tacit eagle
#

Yes, but you have to cast it

#

(this is a cast)
((this is the class you are casting to) this is the object you are casting)

random crypt
#

OHH

#

((WcmLivingEntityAccess) target).setLastDamageTaken(0);

tacit eagle
#

yep

random crypt
#

Took me a second there

tacit eagle
#

But you also need to change the timeUntilRegen

#

Except I'm not exactly sure what to set the value to

#

Try setting it to 20, and if that doesn't work, do 0

random crypt
tacit eagle
#

No

random crypt
#

Hm

tacit eagle
#

TimeUntilRegen is a public field

random crypt
#

Oh!

#

Yay

#

Time to test?

tacit eagle
#

Yep

random crypt
#

It crashed

tacit eagle
#

What's the log

random crypt
#

Changed target.timeUntilRegen to 0 just to check and it crashed again
Time to check the logs!

#

It is trying to invoke "net.minecraft.entity.player.PlayerEntity.getMainHandStack()" but it cannot because "playerEntity" is null

tacit eagle
#

Add a null check then

random crypt
#

PlayerEntity playerEntity = (PlayerEntity) (Object) ((LivingEntity) target).getAttacker();
I assume it is something with this

#

OH

random crypt
#

Yeah, I changed it around

#

PlayerEntity playerEntity = (PlayerEntity) (Object) this;

#

AND IT WORKS

tacit eagle
#

👍

random crypt
#

Thank you so, so much Sky

#

You have helped me so much, I feel terrible not being able to offer anything

tacit eagle
#

It's fine

#

Actually me helping you has prompted me to question what value I should set the timeUntilRegen to avoid iframes

#

Because it seems like the mod I'm using doesn't do it properly, but I don't know if it was intended or not