-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+Added useful limit data for modders to use; each attribute is assigned a minimum, maximum, increment value and chance weighting. None of these do anything or influence any function of the api mod, they are simply there so that other mods that have to assign values no longer have to and are compatible with other attributes. +Updated to 1.1.3.
- Loading branch information
1 parent
f902041
commit 3bff108
Showing
6 changed files
with
132 additions
and
48 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
65 changes: 65 additions & 0 deletions
65
src/main/java/com/github/clevernucleus/playerex/api/Limit.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,65 @@ | ||
package com.github.clevernucleus.playerex.api; | ||
|
||
/** | ||
* Holds four values needed for attribute manipulation required by chance-based mods. | ||
*/ | ||
public class Limit { | ||
private double increment, minValue, maxValue, weight; | ||
|
||
private Limit(final double par0, final double par1, final double par2, final double par3) { | ||
this.increment = (par0 < par2 ? par0 : 0D); | ||
this.minValue = (par1 < par2 ? par1 : 0D); | ||
this.maxValue = (par2 > par1 ? par2 : par0 + par1); | ||
this.weight = Math.min(Math.max(par3, 0D), 1D); | ||
} | ||
|
||
/** | ||
* @param par0 Increment Value (must be less than the Max Value). | ||
* @param par1 Min Value (must be less than the Max Value). | ||
* @param par2 Max Value (must be greater than the Min Value). | ||
* @param par3 Weight - for random chance; could be interpreted as how rare this attribute is (must be between 0 and 1). | ||
* @return A new Limit instance holding the input parameters. | ||
*/ | ||
public static Limit hold(final double par0, final double par1, final double par2, final double par3) { | ||
return new Limit(par0, par1, par2, par3); | ||
} | ||
|
||
/** | ||
* @return A null-equivalent Limit instance holding [0D, 0D, 0D, 0D]. | ||
*/ | ||
public static Limit none() { | ||
return new Limit(0D, 0D, 0D, 0D); | ||
} | ||
|
||
public double increment() { | ||
return this.increment; | ||
} | ||
|
||
public double minValue() { | ||
return this.minValue; | ||
} | ||
|
||
public double maxValue() { | ||
return this.maxValue; | ||
} | ||
|
||
public double weight() { | ||
return this.weight; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object par0) { | ||
if(par0 == null) return false; | ||
if(par0 == this) return true; | ||
if(!(par0 instanceof Limit)) return false; | ||
|
||
Limit var0 = (Limit)par0; | ||
|
||
return toString().equals(var0.toString()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[incr=" + this.increment + ",min=" + this.minValue + ",max=" + this.maxValue + ",weight=" + this.weight + "]"; | ||
} | ||
} |
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
Oops, something went wrong.