Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add i18n code #17

Merged
merged 5 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/main/java/com/encraft/dz/gui/GiuInvBuildingKit.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.encraft.dz.gui;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

import org.lwjgl.opengl.GL11;

Expand Down Expand Up @@ -50,23 +50,24 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
if (slotek != null) {
co_wnim = slotek.getDisplayName();
} else {
co_wnim = "Empty";
co_wnim = StatCollector.translateToLocal("IFU.Empty");
}

String s = inventory.hasCustomInventoryName() ? inventory.getInventoryName()
: I18n.format(inventory.getInventoryName());
String s = StatCollector.translateToLocal(inventory.getInventoryName());

fontRendererObj.drawString(s, 50, 12, 4210752);
int width = fontRendererObj.getStringWidth(s);
fontRendererObj.drawString(s, 88 - width / 2, 12, 4210752);

String[] blacklisted = cfg.blacklist;
for (String ss : blacklisted) {
if (ss != null && slotek != null && ss.equals(slotek.getUnlocalizedName())) {
fontRendererObj.drawString("! Blacklisted block !", 27, ySize - 116, 4210752);
fontRendererObj
.drawString(StatCollector.translateToLocal("IFU.BlacklistedBlock"), 27, ySize - 116, 4210752);
break;
}
}

fontRendererObj.drawString("Name: " + co_wnim, 10, ySize - 96, 4210752);
fontRendererObj.drawString(StatCollector.translateToLocal("IFU.NameTip") + co_wnim, 10, ySize - 96, 4210752);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void setInventorySlotContents(int slot, ItemStack stack) {

@Override
public String getInventoryName() {
return name;
return "item.ifu_buildingKit.name";
}

@Override
Expand Down
30 changes: 22 additions & 8 deletions src/main/java/com/encraft/dz/items/ItemOreFinderTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;

import com.encraft.dz.DayNMod;
Expand Down Expand Up @@ -263,17 +264,31 @@ public void addInformation(ItemStack itemStack, EntityPlayer player, List list,
toFindStr3 = splitFind[0] + "." + splitFind[1] + "." + tMetaID;
}
}
if (!toFindStr2.isEmpty()) list.add("I want to find: " + toFindStr2);
// if (!toFindStr2.isEmpty()) list.add("I want to find: " + toFindStr2);
if (!toFindStr2.isEmpty()) list.add(StatCollector.translateToLocal("IFU.FindTarget") + toFindStr2);
if (!toFindStr3.isEmpty()) list.add(toFindStr3);
list.add("Put ore block you want to find in item inventory -");
list.add("SHIFT+RIGHT CLICK on ground to open inventory");
list.add("You can only use 1 finder at a time");
list.add("Search radius X, Z: " + ConfigHandler.xzAreaRadius + " Y: " + ConfigHandler.yAreaRadius);

list.add(StatCollector.translateToLocal("IFU.description1"));
list.add(StatCollector.translateToLocal("IFU.description2"));
list.add(StatCollector.translateToLocal("IFU.description3"));
list.add(
StatCollector.translateToLocalFormatted(
"IFU.SearchRadiusText",
ConfigHandler.xzAreaRadius,
ConfigHandler.yAreaRadius));

if (!ConfigHandler.aEnableEverywhere) {
list.add("** DOES NOT WORK IN SPACE! **");
list.add("Overworld, Nether, Twilight Forest only");
list.add(StatCollector.translateToLocal("IFU.disableAtSomewhereWarning1"));
list.add(StatCollector.translateToLocal("IFU.disableAtSomewhereWarning2"));
}

/*
* list.add("Put ore block you want to find in item inventory -");
* list.add("SHIFT+RIGHT CLICK on ground to open inventory");
* list.add("You can only use 1 finder at a time"); list.add("Search radius X, Z: " + *
* ConfigHandler.xzAreaRadius + " " + ConfigHandler.yAreaRadius); if (!ConfigHandler.aEnableEverywhere) {
* list.add("** DOES NOT WORK IN SPACE! **"); list.add("Overworld, Nether, Twilight Forest only"); }
*/
}
}

Expand All @@ -282,7 +297,6 @@ public boolean onItemUse(ItemStack itemstack, EntityPlayer entityPlayer, World w

if (entityPlayer.isSneaking()) {
if (!world.isRemote) {

entityPlayer.openGui(
DayNMod.instance,
DayNMod.GUI_CUSTOM_INV1,
Expand Down
12 changes: 11 additions & 1 deletion src/main/resources/assets/ifu/lang/en_US.lang
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
item.ifu_buildingKit.name=Ore Finder Wand
itemGroup.DayNModTools=IFU
itemGroup.DayNModTools=IFU
IFU.FindTarget=I want to find:
IFU.description1=Put ore block you want to find in item inventory -"
IFU.description2=SHIFT+RIGHT CLICK on ground to open inventory
IFU.description3=You can only use 1 finder at a time
IFU.SearchRadiusText=Search radius X, Z: %s Y: %s
IFU.disableAtSomewhereWarning1=** DOES NOT WORK IN SPACE! **
IFU.disableAtSomewhereWarning2=Overworld, Nether, Twilight Forest only
IFU.BlacklistedBlock=! Blacklisted block !
IFU.NameTip=Name :
IFU.Empty=Empty
12 changes: 11 additions & 1 deletion src/main/resources/assets/ifu/lang/zh_CN.lang
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
item.ifu_buildingKit.name=寻矿魔杖
itemGroup.DayNModTools=寻矿魔杖
itemGroup.DayNModTools=寻矿魔杖
IFU.FindTarget=正在寻找
IFU.description1=在物品格中放入你要寻找的矿石方块
IFU.description2=对着地面shift+右击打开GUI
IFU.description3=一次只可以寻找一种方块
IFU.SearchRadiusText=X轴和Z轴的搜索半径为%s,Y轴搜索半径为%s
IFU.disableAtSomewhereWarning1=**无法在地球之外使用**
IFU.disableAtSomewhereWarning2=只可在主世界、下界与暮色森林使用!
IFU.BlacklistedBlock=黑名单方块!
IFU.NameTip=名称:
IFU.Empty=空