Skip to content

Commit

Permalink
Fix potential server crash while constructing biome item names
Browse files Browse the repository at this point in the history
  • Loading branch information
FoundationGames committed Aug 18, 2023
1 parent 44f1afa commit 4cdc6d1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ loader_version=0.14.2
#Fabric api
fabric_version=0.84.0+1.20.1

mod_version = 1.3.1+1.20.1
mod_version = 1.3.1.a+1.20.1
maven_group = io.github.foundationgames
archives_base_name = sandwichable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
this.drawMouseoverTooltip(context, mouseX, mouseY);
if(waterTankBox.isMouseOver(mouseX, mouseY)) {
List<Text> tooltip = Lists.newArrayList(
Text.literal(((DesalinatorBlockEntity) this.handler.inventory).getWaterAmount() +" B "+ I18n.translate("desalinator.tooltip.filled")),
Text.literal(I18n.translate("desalinator.tooltip.maxCapacity")+" "+DesalinatorBlockEntity.maxFluidAmount +" B")
Text.translatable("desalinator.tooltip.bucketsFilled", ((DesalinatorBlockEntity) this.handler.inventory).getWaterAmount()),
Text.translatable("desalinator.tooltip.bucketsMaxCapacity", DesalinatorBlockEntity.maxFluidAmount)
);
if(this.getScreenHandler().inventory instanceof DesalinatorBlockEntity) {
if(((DesalinatorBlockEntity)this.handler.inventory).getWaterAmount() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.Language;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.village.TradeOffers;
Expand Down Expand Up @@ -149,8 +150,9 @@ public static int getSaltyWaterColor() {

public static String biomeName(Identifier id) {
var key = id.toTranslationKey("biome");
if (I18n.hasTranslation(key)) {
return I18n.translate(key);
var lang = Language.getInstance();
if (lang != null && lang.hasTranslation(key)) {
return lang.get(key);
}

var path = id.getPath();
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/sandwichable/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@
"kitchen_knife.tooltip.items_cut": "Cuts %s items",
"kitchen_knife.tooltip.items_cut_singular": "Cuts %s item",

"desalinator.tooltip.filled": "Filled",
"desalinator.tooltip.maxCapacity": "Max Capacity:",
"desalinator.tooltip.bucketsFilled": "%s B Filled",
"desalinator.tooltip.bucketsMaxCapacity": "Max Capacity: %s B",
"desalinator.tooltip.saline": "Salinity Level HIGH",
"desalinator.tooltip.notSaline": "Salinity Level LOW",
"desalinator.tooltip.moveToSaltyBiome": "Please move to a saltwater area or biome!",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/sandwichable/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@

"cheese_culture_bottle.tooltip.uses": "剩余:%d/10",

"desalinator.tooltip.filled": "已装满",
"desalinator.tooltip.maxCapacity": "最大容量:",
"desalinator.tooltip.bucketsFilled": "%s B 已装满",
"desalinator.tooltip.bucketsMaxCapacity": "最大容量:%s B",
"desalinator.tooltip.saline": "盐分含量:高",
"desalinator.tooltip.notSaline": "盐分含量:低",
"desalinator.tooltip.moveToSaltyBiome": "请移至咸水区域/生物群系!",
Expand Down

0 comments on commit 4cdc6d1

Please sign in to comment.