Skip to content

Commit

Permalink
Visual and config fixes
Browse files Browse the repository at this point in the history
*Fixed small config -> server/client issue with the chunk based experience system.
*Fixed small visual issue when attributes had attribute properties 'weight'/'percentage' and had a MULTIPLY type attribute function. 
+Added client-side config option to adjust height of level nameplate.
  • Loading branch information
CleverNucleus committed Jan 17, 2023
1 parent 6b16f2a commit 830e65a
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.18.2
yarn_mappings=1.18.2+build.4
loader_version=0.14.10

mod_version = 3.4.0
mod_version = 3.4.1
maven_group = com.github.clevernucleus
archives_base_name = playerex

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,10 @@ public interface ExConfig {
* @return 0 - 0.75. Size multiplier for PlayerEx gui text in the y-axis.
*/
float textScaleY();

/**
* Client option.
* @return If nameplates have been enabled by the server, this determines for the client the height offset.
*/
float levelNameplateHeight();
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static void appendChildrenToTooltip(List<Text> tooltip, final Supplier<En
for(var child : attribute.children().entrySet()) {
IEntityAttribute attribute2 = child.getKey();
IAttributeFunction function = child.getValue();
double value = function.value() * (function.behaviour() == FunctionBehaviour.MULTIPLY ? 100.0D : 1.0D);
double value = function.value() * ((function.behaviour() == FunctionBehaviour.MULTIPLY && !attribute2.hasProperty(ExAPI.MULTIPLIER_PROPERTY) && !attribute2.hasProperty(ExAPI.PERCENTAGE_PROPERTY)) ? 100.0D : 1.0D);
double displ = displayValue(() -> (EntityAttribute)attribute2, value);
String formt = formatValue(() -> (EntityAttribute)attribute2, function.behaviour(), displ);
MutableText mutableText = new LiteralText(formt + " ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ public static enum Tooltip { DEFAULT, VANILLA, PLAYEREX; }

@ConfigEntry.Category(value = "server")
@ConfigEntry.Gui.Tooltip(count = 2)
private int restorativeForceTicks = 600;
protected int restorativeForceTicks = 600;

@ConfigEntry.Category(value = "server")
@ConfigEntry.BoundedDiscrete(min = 101, max = 200)
@ConfigEntry.Gui.Tooltip(count = 2)
private int restorativeForceMultiplier = 110;
protected int restorativeForceMultiplier = 110;

@ConfigEntry.Category(value = "server")
@ConfigEntry.BoundedDiscrete(min = 1, max = 100)
@ConfigEntry.Gui.Tooltip(count = 2)
private int expNegationFactor = 95;
protected int expNegationFactor = 95;

@ConfigEntry.Category(value = "client")
@ConfigEntry.BoundedDiscrete(min = 0, max = 150)
Expand All @@ -67,6 +67,10 @@ public static enum Tooltip { DEFAULT, VANILLA, PLAYEREX; }
@ConfigEntry.Gui.Tooltip
private int textScaleY = 50;

@ConfigEntry.Category(value = "client")
@ConfigEntry.Gui.Tooltip
private float levelNameplateHeight = 0.3F;

@ConfigEntry.Category(value = "client")
@ConfigEntry.Gui.Tooltip
private Tooltip tooltip = Tooltip.PLAYEREX;
Expand Down Expand Up @@ -111,17 +115,17 @@ public int requiredXp(final PlayerEntity player) {

@Override
public int restorativeForceTicks() {
return this.restorativeForceTicks;
return ConfigServer.INSTANCE.restorativeForceTicks;
}

@Override
public float restorativeForceMultiplier() {
return (float)this.restorativeForceMultiplier * 0.01F;
return (float)ConfigServer.INSTANCE.restorativeForceMultiplier * 0.01F;
}

@Override
public float expNegationFactor() {
return (float)this.expNegationFactor * 0.01F;
return (float)ConfigServer.INSTANCE.expNegationFactor * 0.01F;
}

@Override
Expand All @@ -143,4 +147,9 @@ public float textScaleX() {
public float textScaleY() {
return (this.textScaleY + 25) * 0.01F;
}

@Override
public float levelNameplateHeight() {
return this.levelNameplateHeight;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.objecthunter.exp4j.function.Function;

public final class ConfigServer {
private static final String RESET_ON_DEATH = "ResetOnDeath", DISABLE_ATTRIBUTES_GUI = "DisableAttributesGui", SKILL_POINTS_PER_LEVEL_UP = "SkillPointsPerLevelUp", LEVEL_NAMEPLATE = "LevelNameplate", LEVEL_FORMULA = "LevelFormula", VARIABLE = "x";
private static final String RESET_ON_DEATH = "ResetOnDeath", DISABLE_ATTRIBUTES_GUI = "DisableAttributesGui", SKILL_POINTS_PER_LEVEL_UP = "SkillPointsPerLevelUp", LEVEL_NAMEPLATE = "LevelNameplate", LEVEL_FORMULA = "LevelFormula", VARIABLE = "x", RESTORATIVE_FORCE_TICKS = "RestorativeForceTicks", RESTORATIVE_FORCE_MULTIPLIER = "RestorativeForceMultiplier", EXP_NEGATION_FACTOR = "ExpNegationFactor";

/**
* stairs(x, stretch, steepness, x-offset, y-offset, y-limit)
Expand All @@ -25,6 +25,9 @@ public double apply(double... args) {
protected boolean disableAttributesGui;
protected boolean showLevelNameplates;
protected int skillPointsPerLevelUp;
protected int restorativeForceTicks;
protected int restorativeForceMultiplier;
protected int expNegationFactor;
protected String levelFormula;
private Expression expression;

Expand All @@ -39,6 +42,9 @@ protected void init(final ConfigImpl config) {
this.disableAttributesGui = config.disableAttributesGui;
this.showLevelNameplates = config.showLevelNameplates;
this.skillPointsPerLevelUp = config.skillPointsPerLevelUp;
this.restorativeForceTicks = config.restorativeForceTicks;
this.restorativeForceMultiplier = config.restorativeForceMultiplier;
this.expNegationFactor = config.expNegationFactor;
this.levelFormula = config.levelFormula;
this.expression = this.createExpression();
}
Expand All @@ -53,6 +59,9 @@ public void readFromNbt(NbtCompound tag) {
this.disableAttributesGui = tag.getBoolean(DISABLE_ATTRIBUTES_GUI);
this.showLevelNameplates = tag.getBoolean(LEVEL_NAMEPLATE);
this.skillPointsPerLevelUp = tag.getInt(SKILL_POINTS_PER_LEVEL_UP);
this.restorativeForceTicks = tag.getInt(RESTORATIVE_FORCE_TICKS);
this.restorativeForceMultiplier = tag.getInt(RESTORATIVE_FORCE_MULTIPLIER);
this.expNegationFactor = tag.getInt(EXP_NEGATION_FACTOR);
this.levelFormula = tag.getString(LEVEL_FORMULA);
this.expression = this.createExpression();
}
Expand All @@ -61,6 +70,9 @@ public void writeToNbt(NbtCompound tag) {
tag.putBoolean(RESET_ON_DEATH, this.resetOnDeath);
tag.putBoolean(DISABLE_ATTRIBUTES_GUI, this.disableAttributesGui);
tag.putBoolean(LEVEL_NAMEPLATE, this.showLevelNameplates);
tag.putInt(RESTORATIVE_FORCE_TICKS, this.restorativeForceTicks);
tag.putInt(RESTORATIVE_FORCE_MULTIPLIER, this.restorativeForceMultiplier);
tag.putInt(EXP_NEGATION_FACTOR, this.expNegationFactor);
tag.putInt(SKILL_POINTS_PER_LEVEL_UP, this.skillPointsPerLevelUp);
tag.putString(LEVEL_FORMULA, this.levelFormula);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void playerex_renderLevel(T entity, Text text, MatrixStack matrices, Ver

if(!(d > 4096.0D)) {
boolean bl = !entity.isSneaky();
float f = entity.getHeight() + 0.3F;
float f = entity.getHeight() + ExAPI.getConfig().levelNameplateHeight();
int i = 0;
matrices.push();
matrices.translate(0.0D, (double)f, 0.0D);
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/playerex/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
"text.autoconfig.playerex.option.textScaleX.@Tooltip": "The x-squeeze of the gui text.",
"text.autoconfig.playerex.option.textScaleY": "Vertical Text Scale",
"text.autoconfig.playerex.option.textScaleY.@Tooltip": "The y-squeeze of the gui text.",
"text.autoconfig.playerex.option.levelNameplateHeight": "Level Nameplate Height",
"text.autoconfig.playerex.option.levelNameplateHeight.@Tooltip": "The level nameplate height offset.",
"text.autoconfig.playerex.option.tooltip": "Tooltip Attributes",
"text.autoconfig.playerex.option.tooltip.@Tooltip": "DEFAULT: no change to the tooltip (for mod compatibility).\nVANILLA: fixes attack damage/speed not showing their true value.\nPLAYEREX: attack damage/speed display as regular attribute modifiers.",
"text.autoconfig.playerex.option.darkMode": "Dark Mode",
"playerex.command.reset": "Reset attributes to default values for player %s",
"playerex.command.refund": "Refunded %s skill points for player %s",
"playerex.command.refund_alt": "Refunded 1 skill point for player %s",
Expand Down
28 changes: 20 additions & 8 deletions src/main/resources/assets/playerex/lang/es_mx.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
"text.autoconfig.playerex.title": "Configuración de PlayerEx",
"text.autoconfig.playerex.category.server": "Opciones de Servidor",
"text.autoconfig.playerex.category.client": "Opciones de Cliente",

"text.autoconfig.playerex.option.disableAttributesGui": "Deshabilitar GUI de atributos",
"text.autoconfig.playerex.option.disableAttributesGui.@Tooltip[0]": "Oculta las pestañas de inventario y detiene la apertura \nde la interfaz gráfica de usuario de atributos.",
"text.autoconfig.playerex.option.disableAttributesGui.@Tooltip[0]": "Oculta las pesta�as de inventario y detiene la apertura \nde la interfaz gr�fica de usuario de atributos.",
"text.autoconfig.playerex.option.disableAttributesGui.@Tooltip[1]": "(Requiere reiniciar)",

"text.autoconfig.playerex.option.resetOnDeath": "Reiniciar al Morir",
"text.autoconfig.playerex.option.resetOnDeath.@Tooltip[0]": "Reinicia todos los atributos al reaparecer.",
"text.autoconfig.playerex.option.resetOnDeath.@Tooltip[1]": "(Requiere reiniciar)",
Expand All @@ -19,6 +17,17 @@
"text.autoconfig.playerex.option.levelFormula": "Fórmula de Nivelación",
"text.autoconfig.playerex.option.levelFormula.@Tooltip[0]": "El número de puntos de experiencia requeridos para subir de nivel. La variable 'x' \nse refiere a el nivel actual de la entidad; 'x' es requerido.",
"text.autoconfig.playerex.option.levelFormula.@Tooltip[1]": "(Requiere reiniciar)",

"text.autoconfig.playerex.option.restorativeForceTicks": "Restorative Force Ticks",
"text.autoconfig.playerex.option.restorativeForceTicks.@Tooltip[0]": "The number of ticks between every restorative event. \nNote that 20 ticks is 1 second.",
"text.autoconfig.playerex.option.restorativeForceTicks.@Tooltip[1]": "(Requires restart)",
"text.autoconfig.playerex.option.restorativeForceMultiplier": "Restorative Force",
"text.autoconfig.playerex.option.restorativeForceMultiplier.@Tooltip[0]": "The restorative force multiplier.",
"text.autoconfig.playerex.option.restorativeForceMultiplier.@Tooltip[1]": "(Requires restart)",
"text.autoconfig.playerex.option.expNegationFactor": "XP Negation Factor",
"text.autoconfig.playerex.option.expNegationFactor.@Tooltip[0]": "The chance for xp orbs to drop in a given chunk. \nSet to 100 for vanilla behaviour.",
"text.autoconfig.playerex.option.expNegationFactor.@Tooltip[1]": "(Requires restart)",

"text.autoconfig.playerex.option.levelUpVolume": "Volumen al Subir de Nivel",
"text.autoconfig.playerex.option.levelUpVolume.@Tooltip": "Modifica el porcentaje de volumen del sonido.",
"text.autoconfig.playerex.option.skillUpVolume": "Volumen al Subir el Nivel de Habilidad",
Expand All @@ -27,15 +36,18 @@
"text.autoconfig.playerex.option.textScaleX.@Tooltip": "Extender el texto en el eje X.",
"text.autoconfig.playerex.option.textScaleY": "Estiramiento Vertical del Texto",
"text.autoconfig.playerex.option.textScaleY.@Tooltip": "Extender el texto en el eje Y.",

"text.autoconfig.playerex.option.levelNameplateHeight": "Level Nameplate Height",
"text.autoconfig.playerex.option.levelNameplateHeight.@Tooltip": "The level nameplate height offset.",

"text.autoconfig.playerex.option.tooltip": "Descripciones de atributos",
"text.autoconfig.playerex.option.tooltip.@Tooltip": "DEFAULT: sin cambios en las descripciones (para compatibilidad con mods).\nVANILLA: corrige el daño de ataque/velocidad que no muestra su verdadero valor.\nPLAYEREX: el daño de ataque/la velocidad se muestran como otros atributos.",
"text.autoconfig.playerex.option.darkMode": "Modo Oscuro",
"text.autoconfig.playerex.option.tooltip.@Tooltip": "DEFAULT: sin cambios en las descripciones (para compatibilidad con mods).\nVANILLA: corrige el da�o de ataque/velocidad que no muestra su verdadero valor.\nPLAYEREX: el da�o de ataque/la velocidad se muestran como otros atributos.",
"command.playerex.reset": "Reinicia los atributos a sus valores predeterminados para %s",
"command.playerex.refund": "Se le devolvieron %s puntos de habilidad al jugador %s",
"command.playerex.refund_alt": "Se le devolvió 1 punto de habilidad al jugador %s",
"command.playerex.refund_alt": "Se le devolvi� 1 punto de habilidad al jugador %s",
"command.playerex.levelup": "Se le agregaron %s niveles al jugador %s",
"command.playerex.levelup_alt": "Se le agregó 1 nivel al jugador %s",
"command.playerex.attribute_max_error": "El atributo %s ya está en su valor máximo para el jugador %s.",
"command.playerex.levelup_alt": "Se le agreg� 1 nivel al jugador %s",
"command.playerex.attribute_max_error": "El atributo %s ya est� en su valor m�ximo para el jugador %s.",
"playerex.command.skill_attribute": "%s aumentada para el jugador %s.",
"playerex.command.skill_attribute_error": "%s no tiene puntos de habilidad para gastar!",
"playerex.command.refund_attribute": "%s reembolsada para el jugador %s.",
Expand Down
16 changes: 15 additions & 1 deletion src/main/resources/assets/playerex/lang/ko_kr.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
"text.autoconfig.playerex.option.levelFormula": "레벨 업 공식",
"text.autoconfig.playerex.option.levelFormula.@Tooltip[0]": "레벨 업에 필요한 경험치 포인트입니다.\n'x' 변수는 플레이어의 현재 레벨을 의미합니다. 'x'는 필수 값입니다.",
"text.autoconfig.playerex.option.levelFormula.@Tooltip[1]": "(다시 시작 필요)",

"text.autoconfig.playerex.option.restorativeForceTicks": "Restorative Force Ticks",
"text.autoconfig.playerex.option.restorativeForceTicks.@Tooltip[0]": "The number of ticks between every restorative event. \nNote that 20 ticks is 1 second.",
"text.autoconfig.playerex.option.restorativeForceTicks.@Tooltip[1]": "(Requires restart)",
"text.autoconfig.playerex.option.restorativeForceMultiplier": "Restorative Force",
"text.autoconfig.playerex.option.restorativeForceMultiplier.@Tooltip[0]": "The restorative force multiplier.",
"text.autoconfig.playerex.option.restorativeForceMultiplier.@Tooltip[1]": "(Requires restart)",
"text.autoconfig.playerex.option.expNegationFactor": "XP Negation Factor",
"text.autoconfig.playerex.option.expNegationFactor.@Tooltip[0]": "The chance for xp orbs to drop in a given chunk. \nSet to 100 for vanilla behaviour.",
"text.autoconfig.playerex.option.expNegationFactor.@Tooltip[1]": "(Requires restart)",

"text.autoconfig.playerex.option.levelUpVolume": "레벨 업 볼륨",
"text.autoconfig.playerex.option.levelUpVolume.@Tooltip": "볼륨 배율 (퍼센트)",
"text.autoconfig.playerex.option.skillUpVolume": "스킬 업 볼륨",
Expand All @@ -25,9 +36,12 @@
"text.autoconfig.playerex.option.textScaleX.@Tooltip": "gui 텍스트의 x 스퀴즈.",
"text.autoconfig.playerex.option.textScaleY": "세로 텍스트 크기",
"text.autoconfig.playerex.option.textScaleY.@Tooltip": "gui 텍스트의 y 스퀴즈.",

"text.autoconfig.playerex.option.levelNameplateHeight": "Level Nameplate Height",
"text.autoconfig.playerex.option.levelNameplateHeight.@Tooltip": "The level nameplate height offset.",

"text.autoconfig.playerex.option.tooltip": "특성 툴팁",
"text.autoconfig.playerex.option.tooltip.@Tooltip": "DEFAULT: 툴팁 (모드 호환)을 변경하지 않습니다.\nVANILLA: 공격 데미지/속도 값을 실제 값으로 표시하지 않습니다.\nPLAYEREX: 공격 데미지/속도 값을 일반 특성 수정자로 표시합니다.",
"text.autoconfig.playerex.option.darkMode": "다크 모드",
"playerex.command.reset": "플레이어 %s 값을 기본값으로 초기화합니다.",
"playerex.command.refund": "스킬 포인트 %s를 플레이어 %s에게 돌려줍니다.",
"playerex.command.refund_alt": "스킬 포인트 1을 플레이어 %s에게 돌려줍니다.",
Expand Down
16 changes: 15 additions & 1 deletion src/main/resources/assets/playerex/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
"text.autoconfig.playerex.option.levelFormula": "Формула повышения уровня",
"text.autoconfig.playerex.option.levelFormula.@Tooltip[0]": "Количество очков опыта, необходимое для повышения уровня.\n'x' переменная относится к текущему уровню игрока; 'x' обязательна.",
"text.autoconfig.playerex.option.levelFormula.@Tooltip[1]": "(Требуется перезагрузка)",

"text.autoconfig.playerex.option.restorativeForceTicks": "Restorative Force Ticks",
"text.autoconfig.playerex.option.restorativeForceTicks.@Tooltip[0]": "The number of ticks between every restorative event. \nNote that 20 ticks is 1 second.",
"text.autoconfig.playerex.option.restorativeForceTicks.@Tooltip[1]": "(Requires restart)",
"text.autoconfig.playerex.option.restorativeForceMultiplier": "Restorative Force",
"text.autoconfig.playerex.option.restorativeForceMultiplier.@Tooltip[0]": "The restorative force multiplier.",
"text.autoconfig.playerex.option.restorativeForceMultiplier.@Tooltip[1]": "(Requires restart)",
"text.autoconfig.playerex.option.expNegationFactor": "XP Negation Factor",
"text.autoconfig.playerex.option.expNegationFactor.@Tooltip[0]": "The chance for xp orbs to drop in a given chunk. \nSet to 100 for vanilla behaviour.",
"text.autoconfig.playerex.option.expNegationFactor.@Tooltip[1]": "(Requires restart)",

"text.autoconfig.playerex.option.levelUpVolume": "Громкость повышения уровня",
"text.autoconfig.playerex.option.levelUpVolume.@Tooltip": "Множитель громкости в процентах.",
"text.autoconfig.playerex.option.skillUpVolume": "Громкость повышения навыков",
Expand All @@ -25,9 +36,12 @@
"text.autoconfig.playerex.option.textScaleX.@Tooltip": "Сжатие текста по 'x'.",
"text.autoconfig.playerex.option.textScaleY": "Масштаб вертикального текста",
"text.autoconfig.playerex.option.textScaleY.@Tooltip": "Сжатие текста по 'y'.",

"text.autoconfig.playerex.option.levelNameplateHeight": "Level Nameplate Height",
"text.autoconfig.playerex.option.levelNameplateHeight.@Tooltip": "The level nameplate height offset.",

"text.autoconfig.playerex.option.tooltip": "Подсказки характеристик",
"text.autoconfig.playerex.option.tooltip.@Tooltip": "ПО УМОЛЧАНИЮ: всплывающая подсказка не изменяется (для совместимости с модами).\nVANILLA: исправляет урон/скорость атаки, не отображающие их истинное значение.\nPLAYEREX: отображение урона/скорости атаки в качестве обычных параметров характеристик.",
"text.autoconfig.playerex.option.darkMode": "Темный режим",
"playerex.command.reset": "Сбросить характеристики по умолчанию для игрока %s",
"playerex.command.refund": "Вернуть %s очков навыка для игрока %s",
"playerex.command.refund_alt": "Возвращено 1 очко умений для игрока %s",
Expand Down
Loading

0 comments on commit 830e65a

Please sign in to comment.