Skip to content

Commit

Permalink
v3.9.1 b730
Browse files Browse the repository at this point in the history
* resolved issue with mobs having default health
* tweaked debug messages for `ATTRIBUTE_MULTIPLIERS`
  • Loading branch information
stumper66 committed Dec 20, 2022
1 parent 8694975 commit d93c208
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.lokka30</groupId>
<artifactId>LevelledMobs</artifactId>
<version>3.9.1 b729</version>
<version>3.9.1 b730</version>
<packaging>jar</packaging>
<name>LevelledMobs</name>
<description>The Ultimate RPG Mob Levelling Plugin</description>
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/me/lokka30/levelledmobs/managers/MobDataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ void setAdditionsForLevel(@NotNull final LivingEntityWrapper lmEntity,
(float) Objects.requireNonNull(getAttributeDefaultValue(lmEntity, attribute)) :
(float) Objects.requireNonNull(lmEntity.getLivingEntity().getAttribute(attribute))
.getBaseValue();
final double additionValue = getAdditionsForLevel(lmEntity, addition, defaultValue);
final float additionValue = getAdditionsForLevel(lmEntity, addition, defaultValue);

if (additionValue == 0.0) {
if (additionValue == 0.0f) {
return;
}

Expand Down Expand Up @@ -179,12 +179,8 @@ public final float getAdditionsForLevel(
final Addition addition,
final float defaultValue
) {
debugLog(main, ATTRIBUTE_MULTIPLIERS,
"Getting additions for level for entity '" + lmEntity.getTypeName() + "'.");

final float maxLevel = main.rulesManager.getRuleMobMaxLevel(lmEntity);

//double attributeValue = 0;
final FineTuningAttributes fineTuning = lmEntity.getFineTuningAttributes();
FineTuningAttributes.Multiplier multiplier = null;
float attributeMax = 0;
Expand All @@ -200,19 +196,21 @@ public final float getAdditionsForLevel(
}
}

if (maxLevel == 0 || multiplier == null) {
debugLog(main, ATTRIBUTE_MULTIPLIERS, "maxLevel=0 / multiplier=null; returning 0");
if (maxLevel == 0 || multiplier == null || multiplier.value() == 0.0f) {
debugLog(main, ATTRIBUTE_MULTIPLIERS, lmEntity.getNameIfBaby() +
", maxLevel=0 / multiplier=null; returning 0 for " + addition);
return 0.0f;
}

final float multiplierValue = multiplier.value();
debugLog(main, ATTRIBUTE_MULTIPLIERS, "MultiplierValue: " + multiplierValue);

if (fineTuning.useStacked || multiplier.useStacked()) {
debugLog(main, ATTRIBUTE_MULTIPLIERS, "Using stacked formula");
if (fineTuning.useStacked != null && fineTuning.useStacked || multiplier.useStacked()) {
debugLog(main, ATTRIBUTE_MULTIPLIERS, multiplier +
", using stacked formula");
return (float) lmEntity.getMobLevel() * multiplierValue;
} else {
debugLog(main, ATTRIBUTE_MULTIPLIERS, "Using standard formula");
debugLog(main, ATTRIBUTE_MULTIPLIERS, multiplier +
", using standard formula");

if (attributeMax > 0.0) {
// only used for 5 specific attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public FineTuningAttributes(){
this.multipliers = new LinkedHashMap<>();
}

private final Map<Addition, Multiplier> multipliers;
private Map<Addition, Multiplier> multipliers;
public boolean doNotMerge;
public Boolean useStacked = false;
public Boolean useStacked;

public boolean isEmpty(){
return this.multipliers.isEmpty();
Expand All @@ -36,7 +36,7 @@ void mergeAttributes(final @Nullable FineTuningAttributes attributes) {
return;
}

this.multipliers.putAll(attributes.multipliers);
this.multipliers.putAll(attributes.copyMultipliers());
}

public void addItem(final Addition addition, final Multiplier multiplier){
Expand Down Expand Up @@ -92,7 +92,6 @@ public void addItem(final Addition addition, final Multiplier multiplier){
}

public record Multiplier(Addition addition, boolean useStacked, float value){

@Contract(pure = true)
public @NotNull String toString(){
final StringBuilder sb = new StringBuilder();
Expand All @@ -109,13 +108,31 @@ public FineTuningAttributes cloneItem() {
FineTuningAttributes copy = null;
try {
copy = (FineTuningAttributes) super.clone();
copy.cloneMultipliers();
} catch (final Exception e) {
e.printStackTrace();
}

return copy;
}

private void cloneMultipliers(){
final Map<Addition, Multiplier> copy = copyMultipliers();
this.multipliers = new LinkedHashMap<>(copy.size());
this.multipliers.putAll(copy);
}

private @NotNull Map<Addition, Multiplier> copyMultipliers(){
final Map<Addition, Multiplier> copy = new LinkedHashMap<>(this.multipliers.size());

for (final Addition addition : this.multipliers.keySet()){
final Multiplier old = this.multipliers.get(addition);
copy.put(addition, new Multiplier(addition, old.useStacked, old.value));
}

return copy;
}

public String toString() {
if (this.isEmpty())
return "No items";
Expand All @@ -131,7 +148,7 @@ public String toString() {
}
sb.append(getShortName(item.addition()));
sb.append(": ");
sb.append(item.value);
sb.append(item.value());
if (item.useStacked()){
sb.append(" (");
sb.append("stk)");
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ presets:
# Special Multipliers (0.0 Min - 1.0 Max)
armor-bonus: 0.2
armor-toughness: 0.15
## optional: use the stacker multiplier instead
## optional: use the stacked multiplier instead
# max-health: [ '4.25', 'STACKED' ]
# movement-speed: [ '0.002', 'STACKED' ]
# attack-damage: [ '0.25', 'STACKED' ]
Expand Down

0 comments on commit d93c208

Please sign in to comment.