From ff4ebbee20bc2bbd16a3cbf002d20ed69f4689e8 Mon Sep 17 00:00:00 2001 From: ROM Date: Mon, 18 Sep 2023 00:09:04 -0500 Subject: [PATCH] fix: remove calls to loadLanguage --- .../galacticraft/core/GalacticraftCore.java | 10 -- .../core/proxy/ClientProxyCore.java | 12 +-- .../galacticraft/core/util/GCCoreUtil.java | 97 ------------------- .../planets/GalacticraftPlanets.java | 37 +++---- 4 files changed, 16 insertions(+), 140 deletions(-) diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/GalacticraftCore.java b/src/main/java/micdoodle8/mods/galacticraft/core/GalacticraftCore.java index 1aaaa84c98..f2a5a8aa46 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/GalacticraftCore.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/GalacticraftCore.java @@ -562,16 +562,6 @@ public void postInit(FMLPostInitializationEvent event) GalacticraftCore.logger.error("Error initialising JPEG compressor - this is likely caused by OpenJDK - see https://wiki.micdoodle8.com/wiki/Compatibility#For_clients_running_OpenJDK"); e.printStackTrace(); } - - if (event.getSide() == Side.SERVER) - { - this.loadLanguageCore("en_US"); - } - } - - public void loadLanguageCore(String lang) - { - GCCoreUtil.loadLanguage(lang, Constants.ASSET_PREFIX, this.GCCoreSource); } @EventHandler diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/proxy/ClientProxyCore.java b/src/main/java/micdoodle8/mods/galacticraft/core/proxy/ClientProxyCore.java index b7a25178b0..1d64130e6e 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/proxy/ClientProxyCore.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/proxy/ClientProxyCore.java @@ -318,17 +318,7 @@ public void postInit(FMLPostInitializationEvent event) @Override public void onResourceManagerReload(IResourceManager resourceManager, Predicate resourcePredicate) { - String lang = net.minecraft.client.Minecraft.getMinecraft().gameSettings.language; - GalacticraftCore.logger.debug("Reloading entity names for language " + lang); - if (lang == null) - { - lang = "en_us"; - } - GalacticraftCore.instance.loadLanguageCore(lang); - if (!GCCoreUtil.langDisable) - { - GalacticraftPlanets.instance.loadLanguagePlanets(lang); - } + //NOOP } @Override diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/util/GCCoreUtil.java b/src/main/java/micdoodle8/mods/galacticraft/core/util/GCCoreUtil.java index bf8fb763f1..76ff5df38b 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/util/GCCoreUtil.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/util/GCCoreUtil.java @@ -7,27 +7,10 @@ package micdoodle8.mods.galacticraft.core.util; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Random; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -48,7 +31,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.translation.I18n; -import net.minecraft.util.text.translation.LanguageMap; import net.minecraft.world.World; import net.minecraft.world.WorldProvider; import net.minecraft.world.WorldServer; @@ -66,8 +48,6 @@ import micdoodle8.mods.galacticraft.core.network.PacketSimple; import micdoodle8.mods.galacticraft.core.network.PacketSimple.EnumSimplePacket; -import org.apache.commons.io.IOUtils; - /** * Starting with Release 4.1.0 this class will be removed and all methods moved * to a dedicated utility class. At this time all planned utility classes will @@ -241,83 +221,6 @@ public static String lowerCaseNoun(String string) return GCCoreUtil.translate(string).toLowerCase(); } - @Nullable - public static InputStream supplementEntityKeys(InputStream inputstream, String assetprefix) throws IOException - { - ArrayList langLines = new ArrayList<>(); - BufferedReader br = new BufferedReader(new InputStreamReader(inputstream, StandardCharsets.UTF_8)); - String line; - String supplemented = "entity." + assetprefix.toLowerCase() + "."; - - // TODO: We could also load en_US here and have any language keys not in - // the other lang set to the en_US value - - while ((line = br.readLine()) != null) - { - line = line.trim(); - if (!line.isEmpty()) - { - langLines.add(line); - if (line.substring(0, 7).equals("entity.")) - { - langLines.add(supplemented + line.substring(7)); - } - } - } - - ByteArrayOutputStream outputstream = new ByteArrayOutputStream(); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputstream, StandardCharsets.UTF_8.newEncoder())); - for (String outLine : langLines) - writer.write(outLine + "\n"); - writer.close(); - - return new ByteArrayInputStream(outputstream.toByteArray()); - } - - public static void loadLanguage(String langIdentifier, String assetPrefix, File source) - { - if (!lastLang.equals(langIdentifier)) - { - langDisable = false; - } - if (langDisable) - return; - String langFile = "assets/" + assetPrefix + "/lang/" + langIdentifier + ".lang"; - InputStream stream = null; - ZipFile zip = null; - try - { - if (source.isDirectory() && (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) - { - stream = new FileInputStream(new File(source.toURI().resolve(langFile).getPath())); - } else - { - zip = new ZipFile(source); - ZipEntry entry = zip.getEntry(langFile); - if (entry == null) - throw new FileNotFoundException(); - stream = zip.getInputStream(entry); - } - LanguageMap.inject(GCCoreUtil.supplementEntityKeys(stream, assetPrefix)); - } catch (FileNotFoundException fnf) - { - langDisable = true; - } catch (Exception ignore) - { - } finally - { - if (stream != null) - IOUtils.closeQuietly(stream); - try - { - if (zip != null) - zip.close(); - } catch (IOException ignore) - { - } - } - } - public static int getDimensionID(World world) { return world.provider.getDimension(); diff --git a/src/main/java/micdoodle8/mods/galacticraft/planets/GalacticraftPlanets.java b/src/main/java/micdoodle8/mods/galacticraft/planets/GalacticraftPlanets.java index d66e00062d..bdb301c5d6 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/planets/GalacticraftPlanets.java +++ b/src/main/java/micdoodle8/mods/galacticraft/planets/GalacticraftPlanets.java @@ -13,19 +13,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; -import micdoodle8.mods.galacticraft.api.vector.Vector3; -import micdoodle8.mods.galacticraft.core.Constants; -import micdoodle8.mods.galacticraft.core.tile.TileEntityDeconstructor; -import micdoodle8.mods.galacticraft.core.util.ConfigManagerCore; -import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; -import micdoodle8.mods.galacticraft.core.util.GalacticLog; -import micdoodle8.mods.galacticraft.planets.asteroids.AsteroidsModule; -import micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids; -import micdoodle8.mods.galacticraft.planets.datafix.GCPlanetsDataFixers; -import micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars; -import micdoodle8.mods.galacticraft.planets.mars.MarsModule; -import micdoodle8.mods.galacticraft.planets.venus.ConfigManagerVenus; -import micdoodle8.mods.galacticraft.planets.venus.VenusModule; + import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.common.config.Property; @@ -43,7 +31,19 @@ import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; -import net.minecraftforge.fml.relauncher.Side; + +import micdoodle8.mods.galacticraft.api.vector.Vector3; +import micdoodle8.mods.galacticraft.core.Constants; +import micdoodle8.mods.galacticraft.core.tile.TileEntityDeconstructor; +import micdoodle8.mods.galacticraft.core.util.ConfigManagerCore; +import micdoodle8.mods.galacticraft.core.util.GalacticLog; +import micdoodle8.mods.galacticraft.planets.asteroids.AsteroidsModule; +import micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids; +import micdoodle8.mods.galacticraft.planets.datafix.GCPlanetsDataFixers; +import micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars; +import micdoodle8.mods.galacticraft.planets.mars.MarsModule; +import micdoodle8.mods.galacticraft.planets.venus.ConfigManagerVenus; +import micdoodle8.mods.galacticraft.planets.venus.VenusModule; @Mod(modid = Constants.MOD_ID_PLANETS, name = GalacticraftPlanets.NAME, @@ -130,13 +130,6 @@ public void postInit(FMLPostInitializationEvent event) { GalacticraftPlanets.proxy.postInit(event); TileEntityDeconstructor.initialiseRecipeListPlanets(); - if (event.getSide() == Side.SERVER) - this.loadLanguagePlanets("en_US"); - } - - public void loadLanguagePlanets(String lang) - { - GCCoreUtil.loadLanguage(lang, GalacticraftPlanets.ASSET_PREFIX, GCPlanetsSource); } @EventHandler @@ -212,7 +205,7 @@ public static void finishProp(Property prop, String currentCat) { if (propOrder.get(currentCat) == null) { - propOrder.put(currentCat, new ArrayList()); + propOrder.put(currentCat, new ArrayList<>()); } propOrder.get(currentCat).add(prop.getName()); }