The original hotfix is no longer necessary, as all remaning calls to getFullName are fully client-side
This commit is contained in:
abel1502 2025-05-26 11:58:28 +03:00
parent 38c6b4691d
commit 00c73d63c0
No known key found for this signature in database
GPG Key ID: 076926596A536338
2 changed files with 25 additions and 19 deletions

View File

@ -1,6 +1,6 @@
package com.hbm.handler.ability;
import com.hbm.util.i18n.I18nUtil;
import net.minecraft.client.resources.I18n;
public interface IBaseAbility extends Comparable<IBaseAbility> {
public String getName();
@ -9,9 +9,9 @@ public interface IBaseAbility extends Comparable<IBaseAbility> {
return "";
}
// Note: only usable client-side. Server-side, use ChatComponentTranslation manually instead
public default String getFullName(int level) {
//bandaid fix so it doesn't crash servers instantly, TODO: use ChatComponentTranslation
return I18nUtil.format(getName()) + getExtension(level);
return I18n.format(getName()) + getExtension(level);
}
public default boolean isAllowed() {

View File

@ -27,26 +27,32 @@ public class ToolPreset {
this.harvestAbilityLevel = harvestAbilityLevel;
}
public ChatComponentText getMessage() {
if(isNone())
return ChatBuilder.start("[Tool ability deactivated]").color(EnumChatFormatting.GOLD).flush();
public ChatComponentText getMessage() {
if (isNone()) {
return ChatBuilder.start("[Tool ability deactivated]").color(EnumChatFormatting.GOLD).flush();
}
String areaPart = areaAbility.getFullName(areaAbilityLevel);
String harvestPart = harvestAbility.getFullName(harvestAbilityLevel);
boolean hasArea = areaAbility != IToolAreaAbility.NONE;
boolean hasHarvest = harvestAbility != IToolHarvestAbility.NONE;
ChatBuilder builder = ChatBuilder.start("[Enabled ");
ChatBuilder builder = ChatBuilder.start("[Enabled ");
if (hasArea) {
builder.nextTranslation(areaAbility.getName());
builder.next(areaAbility.getExtension(areaAbilityLevel));
}
if(!areaPart.isEmpty())
builder.next(areaPart);
if (hasArea && hasHarvest) {
builder.next(" + ");
}
if(!areaPart.isEmpty() && !harvestPart.isEmpty())
builder.next(" + ");
if(!harvestPart.isEmpty())
builder.next(harvestPart);
return builder.colorAll(EnumChatFormatting.YELLOW).flush();
}
if (hasHarvest) {
builder.nextTranslation(harvestAbility.getName());
builder.next(harvestAbility.getExtension(harvestAbilityLevel));
}
return builder.colorAll(EnumChatFormatting.YELLOW).flush();
}
public boolean isNone() {
return areaAbility == IToolAreaAbility.NONE && harvestAbility == IToolHarvestAbility.NONE;