Created
April 6, 2013 02:37
-
-
Save ZornTaov/5324474 to your computer and use it in GitHub Desktop.
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
package zornco.reploidcraft.modules; | |
import net.machinemuse.api.MuseItemUtils; | |
import net.machinemuse.powersuits.powermodule.PropertyModifierLinearAdditive; | |
import net.minecraft.nbt.NBTTagCompound; | |
public class PropertyModifierIntLinearAdditive extends PropertyModifierLinearAdditive { | |
protected int roundTo = 0; | |
protected int offset = 0; | |
public PropertyModifierIntLinearAdditive(String tradeoffName, double multiplier, int roundTo, int offset) { | |
super(tradeoffName, multiplier); | |
this.roundTo = roundTo; | |
this.offset = offset; | |
} | |
@Override | |
public double applyModifier(NBTTagCompound moduleTag, double value) { | |
long result = (long)(value + multiplier * MuseItemUtils.getDoubleOrZero(moduleTag, tradeoffName)); | |
return roundWithOffset(result, roundTo, offset); | |
} | |
public long roundWithOffset(double input, int roundTo, int offset){ | |
return Math.round((input + offset)/roundTo)*roundTo - offset; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment