Floor values are set for max health, combat regen, health regen, melee damage, and projectile damage when changing them now.

This commit is contained in:
luisc committed 2021-12-04 12:46:53 -06:00
1 parent cd5b4c0633
commit 3c1bc30e44
6 files changed
+16 -12

No files matched your search

+5 -2
View File
@@ -8,6 +8,9 @@ import noppes.npcs.constants.EnumPotionType;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.util.ValueUtil;
import java.math.RoundingMode;
import java.text.DecimalFormat;
public class DataStats {
private float attackStrength = 5;
@@ -173,12 +176,12 @@ public class DataStats {
return attackStrength;
}
public void setAttackStrength(float strength){
attackStrength = strength;
attackStrength = (float)(Math.floor(strength));
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
}
public void setMaxHealth(double maxHealth) {
this.maxHealth = maxHealth;
this.maxHealth = Math.floor(maxHealth);
npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
}
}
@@ -81,7 +81,7 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
public void unFocused(GuiNpcTextField textfield) {
if(textfield.id == 1){
stats.pDamage = Float.parseFloat(textfield.getText());
stats.pDamage = (float)(Math.floor(Float.parseFloat(textfield.getText())));
}
else if(textfield.id == 2){
stats.pImpact = textfield.getInteger();
@@ -83,17 +83,17 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
@Override
public void unFocused(GuiNpcTextField textfield){
if(textfield.id == 0){
stats.maxHealth = Double.parseDouble(textfield.getText());
stats.maxHealth = Math.floor(Double.parseDouble(textfield.getText()));
npc.heal((float)(stats.maxHealth));
}
else if(textfield.id == 1){
stats.aggroRange = textfield.getInteger();
}
else if(textfield.id == 14){
stats.healthRegen = Float.parseFloat(textfield.getText());
stats.healthRegen = (float)(Math.floor(Float.parseFloat(textfield.getText())));
}
else if(textfield.id == 16){
stats.combatRegen = Float.parseFloat(textfield.getText());
stats.combatRegen = (float)(Math.floor(Float.parseFloat(textfield.getText())));
}
}
@@ -1,6 +1,7 @@
package noppes.npcs.scripted.entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
@@ -49,8 +50,8 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
/**
* @return Entity's max health
*/
public float getMaxHealth(){
return entity.getMaxHealth();
public double getMaxHealth(){
return entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue();
}
/**
* @return Whether or not this entity is attacking something
@@ -712,7 +712,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
* @param strength The ranged strength
*/
public void setRangedStrength(float strength){
npc.stats.pDamage = strength;
npc.stats.pDamage = (float)(Math.floor(strength));
}
/**
@@ -897,7 +897,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
* @param regen The combat health regen per second
*/
public void setCombatRegen(float regen){
npc.stats.combatRegen = regen;
npc.stats.combatRegen = (float)(Math.floor(regen));
}
/**
@@ -911,7 +911,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
* @param regen The health regen per second when not in combat
*/
public void setHealthRegen(float regen){
npc.stats.healthRegen = regen;
npc.stats.healthRegen = (float)(Math.floor(regen));
}
@Override
@@ -19,7 +19,7 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
/**
* @return Entity's max health
*/
public float getMaxHealth();
public double getMaxHealth();
/**
* @return Whether or not this entity is attacking something
*/