Implemented charge cost multiplier into getTargetCost method. Added new getRawTargetCost method and a validateTargetCost method.
This commit is contained in:
@ -77,6 +77,11 @@ public abstract class TotemItem extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getTargetCost(ItemStack stack) {
|
public static int getTargetCost(ItemStack stack) {
|
||||||
|
if (!isTotem(stack)) { return -1; }
|
||||||
|
return !isCostDynamic(stack) ? getRawTargetCost(stack) :
|
||||||
|
(int)(getRawTargetCost(stack) * getConfig(stack).getChargeCostMultiplier());
|
||||||
|
}
|
||||||
|
private static int getRawTargetCost(ItemStack stack) {
|
||||||
if (!isTotem(stack)) { return -1; }
|
if (!isTotem(stack)) { return -1; }
|
||||||
return stack.getOrCreateTag().getInt(TAG_TARGET_COST);
|
return stack.getOrCreateTag().getInt(TAG_TARGET_COST);
|
||||||
}
|
}
|
||||||
@ -130,6 +135,15 @@ public abstract class TotemItem extends Item {
|
|||||||
return getConfig(stack).getIsEnabled();
|
return getConfig(stack).getIsEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void validateTargetCost(ItemStack stack, int targetDeaths) {
|
||||||
|
if (!isTotem(stack)) { return; }
|
||||||
|
if (isCostDynamic(stack) && getRawTargetCost(stack) != targetDeaths) {
|
||||||
|
setTargetCost(stack, targetDeaths);
|
||||||
|
} else if (!isCostDynamic(stack) && getRawTargetCost(stack) != getMaxCharge(stack)) {
|
||||||
|
setTargetCost(stack, getMaxCharge(stack));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
|
Reference in New Issue
Block a user