forked from Meldexun/RLTweaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework resistance calculations for better configurability
- Loading branch information
Showing
8 changed files
with
103 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/com/charles445/rltweaker/entity/attribute/ExtendedRangedAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.charles445.rltweaker.entity.attribute; | ||
|
||
import net.minecraft.entity.ai.attributes.IAttribute; | ||
import net.minecraft.entity.ai.attributes.RangedAttribute; | ||
|
||
public abstract class ExtendedRangedAttribute extends RangedAttribute implements AttributeInstanceFactory { | ||
|
||
public ExtendedRangedAttribute(IAttribute parentIn, String unlocalizedNameIn, double defaultValue, | ||
double minimumValueIn, double maximumValueIn) { | ||
super(parentIn, unlocalizedNameIn, defaultValue, minimumValueIn, maximumValueIn); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/charles445/rltweaker/entity/attribute/InversedAttributeInstance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.charles445.rltweaker.entity.attribute; | ||
|
||
import net.minecraft.entity.ai.attributes.AbstractAttributeMap; | ||
import net.minecraft.entity.ai.attributes.AttributeModifier; | ||
import net.minecraft.entity.ai.attributes.IAttribute; | ||
import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance; | ||
|
||
public class InversedAttributeInstance extends ModifiableAttributeInstance { | ||
|
||
public InversedAttributeInstance(AbstractAttributeMap attributeMapIn, IAttribute genericAttributeIn) { | ||
super(attributeMapIn, genericAttributeIn); | ||
} | ||
|
||
@Override | ||
public double computeValue() { | ||
double d0 = this.getBaseValue(); | ||
|
||
for (AttributeModifier attributemodifier : this.getAppliedModifiers(0)) { | ||
d0 -= attributemodifier.getAmount(); | ||
} | ||
|
||
double d1 = d0; | ||
|
||
for (AttributeModifier attributemodifier1 : this.getAppliedModifiers(1)) { | ||
d1 -= d0 * attributemodifier1.getAmount(); | ||
} | ||
|
||
for (AttributeModifier attributemodifier2 : this.getAppliedModifiers(2)) { | ||
d1 *= 1.0D - attributemodifier2.getAmount(); | ||
} | ||
|
||
return this.genericAttribute.clampValue(d1); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public net.minecraft.entity.ai.attributes.ModifiableAttributeInstance field_111136_b # genericAttribute | ||
public net.minecraft.entity.ai.attributes.ModifiableAttributeInstance func_111129_g()D # computeValue | ||
public net.minecraft.entity.ai.attributes.ModifiableAttributeInstance func_180375_b(I)Ljava/util/Collection; # getAppliedModifiers |