mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
localization for custom machines
This commit is contained in:
parent
8f840f5145
commit
933d45faba
@ -11,7 +11,9 @@
|
||||
* Electrolyzing fluids now only takes 20 ticks instead of 60
|
||||
* Batch sizes for water and heavy water have been doubled, effectively increasing throughout 6x
|
||||
* The throughput for electrolysis on chemical plants has been halved (but heavy water still has the output buff, effectively remaining unchanged)
|
||||
* Custom machines now have an optional localization field which allows translations to be added within the config
|
||||
|
||||
## Fixed
|
||||
* Fixed the structure toggle on the world creation screen not working correctly on most world types
|
||||
* Fixed antiknock having a broken sprite and localization
|
||||
* Fixed crash caused by fallout affecting spotlight blocks, crashing the game
|
||||
|
||||
@ -8,10 +8,12 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
@ -58,6 +60,9 @@ public class CustomMachineConfigJSON {
|
||||
writer.beginObject();
|
||||
writer.name("recipeKey").value("paperPress");
|
||||
writer.name("unlocalizedName").value("paperPress");
|
||||
writer.name("localization").beginObject();
|
||||
writer.name("de_DE").value("Papierpresse");
|
||||
writer.endObject();
|
||||
writer.name("localizedName").value("Paper Press");
|
||||
writer.name("fluidInCount").value(1);
|
||||
writer.name("fluidInCap").value(1_000);
|
||||
@ -152,6 +157,12 @@ public class CustomMachineConfigJSON {
|
||||
configuration.recipeKey = machineObject.get("recipeKey").getAsString();
|
||||
configuration.unlocalizedName = machineObject.get("unlocalizedName").getAsString();
|
||||
configuration.localizedName = machineObject.get("localizedName").getAsString();
|
||||
if(machineObject.has("localization")) {
|
||||
JsonObject localization = machineObject.get("localization").getAsJsonObject();
|
||||
for(Entry<String, JsonElement> entry : localization.entrySet()) {
|
||||
configuration.localization.put(entry.getKey(), entry.getValue().getAsString());
|
||||
}
|
||||
}
|
||||
configuration.fluidInCount = machineObject.get("fluidInCount").getAsInt();
|
||||
configuration.fluidInCap = machineObject.get("fluidInCap").getAsInt();
|
||||
configuration.itemInCount = machineObject.get("itemInCount").getAsInt();
|
||||
@ -240,6 +251,7 @@ public class CustomMachineConfigJSON {
|
||||
public String unlocalizedName;
|
||||
/** The display name of this machine */
|
||||
public String localizedName;
|
||||
public HashMap<String, String> localization = new HashMap();;
|
||||
|
||||
public int fluidInCount;
|
||||
public int fluidInCap;
|
||||
|
||||
@ -9,6 +9,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import com.hbm.inventory.SlotPattern;
|
||||
import com.hbm.inventory.container.ContainerMachineCustom;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityCustomMachine;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@ -69,6 +70,8 @@ public class GUIMachineCustom extends GuiInfoContainer {
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.custom.getInventoryName();
|
||||
String localizedName = this.custom.config.localization.get(MainRegistry.proxy.getLanguageCode());
|
||||
if(localizedName != null) name = localizedName;
|
||||
this.fontRendererObj.drawString(name, 68 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
if(custom.config.fluxMode) this.fontRendererObj.drawString("Flux:" + custom.flux,83, 57,0x08FF00);
|
||||
@ -82,14 +85,14 @@ public class GUIMachineCustom extends GuiInfoContainer {
|
||||
if(custom.config.fluxMode){
|
||||
drawTexturedModalRect(guiLeft + 78, guiTop + 54, 192, 122,51 , 15);
|
||||
}
|
||||
if(custom.maxHeat>0) {
|
||||
drawTexturedModalRect(guiLeft + 61, guiTop + 53, 236,0 , 18, 18);
|
||||
if(custom.maxHeat > 0) {
|
||||
drawTexturedModalRect(guiLeft + 61, guiTop + 53, 236, 0, 18, 18);
|
||||
GaugeUtil.drawSmoothGauge(guiLeft + 70, guiTop + 62, this.zLevel, (double) custom.heat / (double) custom.config.maxHeat, 5, 2, 1, 0x7F0000);
|
||||
}
|
||||
int p = custom.progress * 90 / custom.maxProgress;
|
||||
drawTexturedModalRect(guiLeft + 78, guiTop + 119, 192, 0, Math.min(p, 44), 16);
|
||||
if(p > 44) {
|
||||
p-= 44;
|
||||
p -= 44;
|
||||
drawTexturedModalRect(guiLeft + 78 + 44, guiTop + 119, 192, 16, p, 16);
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.hbm.config.CustomMachineConfigJSON;
|
||||
import com.hbm.config.CustomMachineConfigJSON.MachineConfiguration;
|
||||
import com.hbm.main.MainRegistry;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -39,7 +40,8 @@ public class ItemCustomMachine extends ItemBlock {
|
||||
MachineConfiguration conf = CustomMachineConfigJSON.niceList.get(id);
|
||||
|
||||
if(conf != null) {
|
||||
return conf.localizedName;
|
||||
String localized = conf.localization.get(MainRegistry.proxy.getLanguageCode());
|
||||
return localized != null ? localized : conf.localizedName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ import net.minecraft.client.renderer.entity.RenderMinecart;
|
||||
import net.minecraft.client.renderer.entity.RenderSnowball;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.resources.Language;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -2104,4 +2105,10 @@ public class ClientProxy extends ServerProxy {
|
||||
public void playSoundClient(double x, double y, double z, String sound, float volume, float pitch) {
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(new PositionedSoundRecord(new ResourceLocation(sound), volume, pitch, (float) x, (float) y, (float) z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageCode() {
|
||||
Language lang = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage();
|
||||
return lang.getLanguageCode();
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,4 +86,6 @@ public class ServerProxy {
|
||||
}
|
||||
|
||||
public void playSoundClient(double x, double y, double z, String sound, float volume, float pitch) { }
|
||||
|
||||
public String getLanguageCode() { return "en_US"; }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user