From 64263a9f8efa119d2bf2110f04db92e27d1aefbf Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Sun, 14 Jun 2015 17:06:00 -0700 Subject: [PATCH 1/9] Throw more descriptive errors when mods attempt to register invalid global entity IDs. --- .../client/network/NetHandlerPlayClient.java.patch | 14 +++++++++++++- .../net/minecraft/entity/EntityList.java.patch | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 patches/minecraft/net/minecraft/entity/EntityList.java.patch diff --git a/patches/minecraft/net/minecraft/client/network/NetHandlerPlayClient.java.patch b/patches/minecraft/net/minecraft/client/network/NetHandlerPlayClient.java.patch index b3d3008cd1..35603e89d9 100644 --- a/patches/minecraft/net/minecraft/client/network/NetHandlerPlayClient.java.patch +++ b/patches/minecraft/net/minecraft/client/network/NetHandlerPlayClient.java.patch @@ -32,7 +32,19 @@ } public void func_147279_a(S0BPacketAnimation p_147279_1_) -@@ -1127,6 +1134,10 @@ +@@ -735,6 +742,11 @@ + float f = (float)(p_147281_1_.func_149028_l() * 360) / 256.0F; + float f1 = (float)(p_147281_1_.func_149030_m() * 360) / 256.0F; + EntityLivingBase entitylivingbase = (EntityLivingBase)EntityList.func_75616_a(p_147281_1_.func_149025_e(), this.field_147299_f.field_71441_e); ++ if (entitylivingbase == null) ++ { ++ cpw.mods.fml.common.FMLLog.info("Server attempted to spawn an unknown entity using ID: {0} at ({1}, {2}, {3}) Skipping!", p_147281_1_.func_149025_e(), d0, d1, d2); ++ return; ++ } + entitylivingbase.field_70118_ct = p_147281_1_.func_149023_f(); + entitylivingbase.field_70117_cu = p_147281_1_.func_149034_g(); + entitylivingbase.field_70116_cv = p_147281_1_.func_149029_h(); +@@ -1127,6 +1139,10 @@ { tileentity.func_145839_a(p_147273_1_.func_148857_g()); } diff --git a/patches/minecraft/net/minecraft/entity/EntityList.java.patch b/patches/minecraft/net/minecraft/entity/EntityList.java.patch new file mode 100644 index 0000000000..f1c7ee4efc --- /dev/null +++ b/patches/minecraft/net/minecraft/entity/EntityList.java.patch @@ -0,0 +1,10 @@ +--- ../src-base/minecraft/net/minecraft/entity/EntityList.java ++++ ../src-work/minecraft/net/minecraft/entity/EntityList.java +@@ -84,6 +84,7 @@ + + public static void func_75618_a(Class p_75618_0_, String p_75618_1_, int p_75618_2_) + { ++ if (p_75618_2_ < 0 || p_75618_2_ > 255) throw new IllegalArgumentException("Attempted to register a entity with invalid ID: " + p_75618_2_ + " Name: " + p_75618_1_ + " Class: " + p_75618_0_); + if (field_75625_b.containsKey(p_75618_1_)) + { + throw new IllegalArgumentException("ID is already registered: " + p_75618_1_); From c50adf243366cf199f055b51a85e7119a2748ecc Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Tue, 16 Jun 2015 15:26:00 -0700 Subject: [PATCH 2/9] Include the thread state in the potential error handleing for SplashProgress. --- fml/src/main/java/cpw/mods/fml/client/SplashProgress.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java b/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java index cf1c07b8e4..915d2169ad 100644 --- a/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java +++ b/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java @@ -488,9 +488,9 @@ public class SplashProgress public static void finish() { if(!enabled) return; - checkThreadState(); try { + checkThreadState(); done = true; thread.join(); d.releaseContext(); From e7724c13ccecb7d82d482e8ee5b112d252c9d4d1 Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Wed, 17 Jun 2015 15:48:22 -0700 Subject: [PATCH 3/9] Fixed Wavefront Object Importer reading files with integer values. Closes #1651, #1654 --- .../client/model/obj/WavefrontObject.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minecraftforge/client/model/obj/WavefrontObject.java b/src/main/java/net/minecraftforge/client/model/obj/WavefrontObject.java index 530fdfd9e0..ff9dd2f900 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/WavefrontObject.java +++ b/src/main/java/net/minecraftforge/client/model/obj/WavefrontObject.java @@ -26,9 +26,9 @@ import cpw.mods.fml.relauncher.SideOnly; */ public class WavefrontObject implements IModelCustom { - private static Pattern vertexPattern = Pattern.compile("(v( (\\-){0,1}\\d+\\.\\d+){3,4} *\\n)|(v( (\\-){0,1}\\d+\\.\\d+){3,4} *$)"); - private static Pattern vertexNormalPattern = Pattern.compile("(vn( (\\-){0,1}\\d+\\.\\d+){3,4} *\\n)|(vn( (\\-){0,1}\\d+\\.\\d+){3,4} *$)"); - private static Pattern textureCoordinatePattern = Pattern.compile("(vt( (\\-){0,1}\\d+\\.\\d+){2,3} *\\n)|(vt( (\\-){0,1}\\d+\\.\\d+){2,3} *$)"); + private static Pattern vertexPattern = Pattern.compile("(v( (\\-){0,1}\\d+(\\.\\d+)?){3,4} *\\n)|(v( (\\-){0,1}\\d+(\\.\\d+)?){3,4} *$)"); + private static Pattern vertexNormalPattern = Pattern.compile("(vn( (\\-){0,1}\\d+(\\.\\d+)?){3,4} *\\n)|(vn( (\\-){0,1}\\d+(\\.\\d+)?){3,4} *$)"); + private static Pattern textureCoordinatePattern = Pattern.compile("(vt( (\\-){0,1}\\d+\\.\\d+){2,3} *\\n)|(vt( (\\-){0,1}\\d+(\\.\\d+)?){2,3} *$)"); private static Pattern face_V_VT_VN_Pattern = Pattern.compile("(f( \\d+/\\d+/\\d+){3,4} *\\n)|(f( \\d+/\\d+/\\d+){3,4} *$)"); private static Pattern face_V_VT_Pattern = Pattern.compile("(f( \\d+/\\d+){3,4} *\\n)|(f( \\d+/\\d+){3,4} *$)"); private static Pattern face_V_VN_Pattern = Pattern.compile("(f( \\d+//\\d+){3,4} *\\n)|(f( \\d+//\\d+){3,4} *$)"); @@ -49,7 +49,7 @@ public class WavefrontObject implements IModelCustom public WavefrontObject(ResourceLocation resource) throws ModelFormatException { this.fileName = resource.toString(); - + try { IResource res = Minecraft.getMinecraft().getResourceManager().getResource(resource); @@ -60,7 +60,7 @@ public class WavefrontObject implements IModelCustom throw new ModelFormatException("IO Exception reading model format", e); } } - + public WavefrontObject(String filename, InputStream inputStream) throws ModelFormatException { this.fileName = filename; From 716dfdae4752d5e98ed055c2e5684b8116667ff4 Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Thu, 18 Jun 2015 20:11:23 -0700 Subject: [PATCH 4/9] Create config folder in SplashProgress if it does not exist. --- fml/src/main/java/cpw/mods/fml/client/SplashProgress.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java b/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java index 915d2169ad..ac27436b1a 100644 --- a/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java +++ b/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java @@ -536,6 +536,10 @@ public class SplashProgress private static boolean disableSplash() { File configFile = new File(Minecraft.getMinecraft().mcDataDir, "config/splash.properties"); + File parent = configFile.getParentFile(); + if (!parent.exists()) + parent.mkdirs(); + FileReader r = null; enabled = false; config.setProperty("enabled", "false"); From 6527792d0680e497e14f9a5d71f82ab8be24f73d Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Thu, 18 Jun 2015 20:13:17 -0700 Subject: [PATCH 5/9] Add the stitching allocation stage to loading screen. --- .../renderer/texture/Stitcher.java.patch | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 fml/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch diff --git a/fml/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch b/fml/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch new file mode 100644 index 0000000000..ab2cfc4f0d --- /dev/null +++ b/fml/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch @@ -0,0 +1,26 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/texture/Stitcher.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/texture/Stitcher.java +@@ -60,6 +60,7 @@ + public void func_94305_f() + { + Stitcher.Holder[] aholder = (Stitcher.Holder[])this.field_94319_a.toArray(new Stitcher.Holder[this.field_94319_a.size()]); ++ cpw.mods.fml.common.ProgressManager.ProgressBar bar = cpw.mods.fml.common.ProgressManager.push("Texture stitching", aholder.length); + Arrays.sort(aholder); + Stitcher.Holder[] aholder1 = aholder; + int i = aholder.length; +@@ -67,6 +68,7 @@ + for (int j = 0; j < i; ++j) + { + Stitcher.Holder holder = aholder1[j]; ++ bar.step(holder.func_98150_a().func_94215_i()); + + if (!this.func_94310_b(holder)) + { +@@ -80,6 +82,7 @@ + this.field_94318_c = MathHelper.func_151236_b(this.field_94318_c); + this.field_94315_d = MathHelper.func_151236_b(this.field_94315_d); + } ++ cpw.mods.fml.common.ProgressManager.pop(bar); + } + + public List func_94309_g() From 4235ca36ea32a89458e018677418e3fda1b84711 Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Thu, 18 Jun 2015 20:13:31 -0700 Subject: [PATCH 6/9] Make TextureMap for items and blocks skip the first pass of loading/stitching textures. Should decrease loading times for large packs. May cause issues with some mods so use -Dfml.skipFirstTextureLoad=false to disable. --- .../net/minecraft/client/Minecraft.java.patch | 6 ++- .../renderer/texture/TextureMap.java.patch | 54 +++++++++++++++---- .../net/minecraft/client/Minecraft.java.patch | 18 +++---- .../renderer/texture/TextureMap.java.patch | 12 ++--- 4 files changed, 62 insertions(+), 28 deletions(-) diff --git a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch index c5e5abb79e..22438e2524 100644 --- a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -85,15 +85,17 @@ this.func_71361_d("Startup"); + bar.step("Render Global instance"); this.field_71438_f = new RenderGlobal(this); +- this.field_147128_au = new TextureMap(0, "textures/blocks"); + bar.step("Building Blocks Texture"); - this.field_147128_au = new TextureMap(0, "textures/blocks"); ++ this.field_147128_au = new TextureMap(0, "textures/blocks", true); + bar.step("Anisotropy and Mipmaps"); this.field_147128_au.func_147632_b(this.field_71474_y.field_151443_J); this.field_147128_au.func_147633_a(this.field_71474_y.field_151442_I); + bar.step("Loading Blocks Texture"); this.field_71446_o.func_130088_a(TextureMap.field_110575_b, this.field_147128_au); +- this.field_71446_o.func_130088_a(TextureMap.field_110576_c, new TextureMap(1, "textures/items")); + bar.step("Loading Items Texture"); - this.field_71446_o.func_130088_a(TextureMap.field_110576_c, new TextureMap(1, "textures/items")); ++ this.field_71446_o.func_130088_a(TextureMap.field_110576_c, new TextureMap(1, "textures/items", true)); + bar.step("Viewport"); GL11.glViewport(0, 0, this.field_71443_c, this.field_71440_d); this.field_71452_i = new EffectRenderer(this.field_71441_e, this.field_71446_o); diff --git a/fml/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch b/fml/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch index 44bf7beb63..45412d2ddb 100644 --- a/fml/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch +++ b/fml/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch @@ -1,14 +1,44 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/texture/TextureMap.java +++ ../src-work/minecraft/net/minecraft/client/renderer/texture/TextureMap.java -@@ -96,6 +96,7 @@ +@@ -35,6 +35,7 @@ + @SideOnly(Side.CLIENT) + public class TextureMap extends AbstractTexture implements ITickableTextureObject, IIconRegister + { ++ private static final boolean ENABLE_SKIP = Boolean.parseBoolean(System.getProperty("fml.skipFirstTextureLoad", "true")); + private static final Logger field_147635_d = LogManager.getLogger(); + public static final ResourceLocation field_110575_b = new ResourceLocation("textures/atlas/blocks.png"); + public static final ResourceLocation field_110576_c = new ResourceLocation("textures/atlas/items.png"); +@@ -47,12 +48,18 @@ + private int field_147637_k = 1; + private final TextureAtlasSprite field_94249_f = new TextureAtlasSprite("missingno"); + private static final String __OBFID = "CL_00001058"; ++ private boolean skipFirst = false; + + public TextureMap(int p_i1281_1_, String p_i1281_2_) + { ++ this(p_i1281_1_, p_i1281_2_, false); ++ } ++ public TextureMap(int p_i1281_1_, String p_i1281_2_, boolean skipFirst) ++ { + this.field_94255_a = p_i1281_1_; + this.field_94254_c = p_i1281_2_; + this.func_110573_f(); ++ this.skipFirst = skipFirst && ENABLE_SKIP; + } + + private void func_110569_e() +@@ -96,15 +103,17 @@ this.field_94252_e.clear(); this.field_94258_i.clear(); int j = Integer.MAX_VALUE; -+ cpw.mods.fml.common.ProgressManager.ProgressBar bar = cpw.mods.fml.common.ProgressManager.push("Texture stitching", this.field_110574_e.size()); ++ cpw.mods.fml.common.ProgressManager.ProgressBar bar = cpw.mods.fml.common.ProgressManager.push("Texture Loading", skipFirst ? 0 : this.field_110574_e.size()); Iterator iterator = this.field_110574_e.entrySet().iterator(); TextureAtlasSprite textureatlassprite; -@@ -105,6 +106,7 @@ +- while (iterator.hasNext()) ++ while (!skipFirst && iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); ResourceLocation resourcelocation = new ResourceLocation((String)entry.getKey()); textureatlassprite = (TextureAtlasSprite)entry.getValue(); ResourceLocation resourcelocation1 = this.func_147634_a(resourcelocation, 0); @@ -16,7 +46,7 @@ try { -@@ -156,12 +158,14 @@ +@@ -156,12 +165,14 @@ } catch (RuntimeException runtimeexception) { @@ -33,7 +63,7 @@ continue; } -@@ -169,6 +173,7 @@ +@@ -169,6 +180,7 @@ stitcher.func_110934_a(textureatlassprite); } @@ -41,24 +71,26 @@ int i1 = MathHelper.func_151239_c(j); if (i1 < this.field_147636_j) -@@ -178,10 +183,12 @@ +@@ -178,10 +190,12 @@ } Iterator iterator1 = this.field_110574_e.values().iterator(); -+ bar = cpw.mods.fml.common.ProgressManager.push("Mipmap generation", this.field_110574_e.size()); ++ bar = cpw.mods.fml.common.ProgressManager.push("Mipmap generation", skipFirst ? 0 : this.field_110574_e.size()); - while (iterator1.hasNext()) +- while (iterator1.hasNext()) ++ while (!skipFirst && iterator1.hasNext()) { final TextureAtlasSprite textureatlassprite1 = (TextureAtlasSprite)iterator1.next(); + bar.step(textureatlassprite1.func_94215_i()); try { -@@ -222,9 +229,12 @@ +@@ -222,9 +236,13 @@ this.field_94249_f.func_147963_d(this.field_147636_j); stitcher.func_110934_a(this.field_94249_f); + cpw.mods.fml.common.ProgressManager.pop(bar); ++ skipFirst = false; + bar = cpw.mods.fml.common.ProgressManager.push("Texture creation", 3); try @@ -67,7 +99,7 @@ stitcher.func_94305_f(); } catch (StitcherException stitcherexception) -@@ -233,10 +243,12 @@ +@@ -233,10 +251,12 @@ } field_147635_d.info("Created: {}x{} {}-atlas", new Object[] {Integer.valueOf(stitcher.func_110935_a()), Integer.valueOf(stitcher.func_110936_b()), this.field_94254_c}); @@ -80,7 +112,7 @@ while (iterator2.hasNext()) { textureatlassprite = (TextureAtlasSprite)iterator2.next(); -@@ -274,6 +286,7 @@ +@@ -274,6 +294,7 @@ textureatlassprite = (TextureAtlasSprite)iterator2.next(); textureatlassprite.func_94217_a(this.field_94249_f); } diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 248ff1af82..abbd9f7bba 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -56,7 +56,7 @@ if (p_147108_1_ instanceof GuiMainMenu) { this.field_71474_y.field_74330_P = false; -@@ -1352,7 +1357,7 @@ +@@ -1353,7 +1358,7 @@ if (this.field_71439_g.func_82246_f(i, j, k)) { @@ -65,7 +65,7 @@ this.field_71439_g.func_71038_i(); } } -@@ -1433,11 +1438,12 @@ +@@ -1434,11 +1439,12 @@ int j = this.field_71476_x.field_72312_c; int k = this.field_71476_x.field_72309_d; @@ -80,7 +80,7 @@ { flag = false; this.field_71439_g.func_71038_i(); -@@ -1464,7 +1470,8 @@ +@@ -1465,7 +1471,8 @@ { ItemStack itemstack1 = this.field_71439_g.field_71071_by.func_70448_g(); @@ -90,7 +90,7 @@ { this.field_71460_t.field_78516_c.func_78445_c(); } -@@ -1676,6 +1683,8 @@ +@@ -1677,6 +1684,8 @@ while (Mouse.next()) { @@ -99,7 +99,7 @@ j = Mouse.getEventButton(); KeyBinding.func_74510_a(j - 100, Mouse.getEventButtonState()); -@@ -2138,6 +2147,11 @@ +@@ -2139,6 +2148,11 @@ public void func_71353_a(WorldClient p_71353_1_, String p_71353_2_) { @@ -111,7 +111,7 @@ if (p_71353_1_ == null) { NetHandlerPlayClient nethandlerplayclient = this.func_147114_u(); -@@ -2150,6 +2164,18 @@ +@@ -2151,6 +2165,18 @@ if (this.field_71437_Z != null) { this.field_71437_Z.func_71263_m(); @@ -130,7 +130,7 @@ } this.field_71437_Z = null; -@@ -2298,113 +2324,10 @@ +@@ -2299,113 +2325,10 @@ if (this.field_71476_x != null) { boolean flag = this.field_71439_g.field_71075_bZ.field_75098_d; @@ -246,7 +246,7 @@ if (flag) { j = this.field_71439_g.field_71069_bz.field_75151_b.size() - 9 + this.field_71439_g.field_71071_by.field_70461_c; -@@ -2670,8 +2593,15 @@ +@@ -2671,8 +2594,15 @@ p_70001_1_.func_152767_b("gl_max_texture_size", Integer.valueOf(func_71369_N())); } @@ -262,7 +262,7 @@ for (int i = 16384; i > 0; i >>= 1) { GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, i, i, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null); -@@ -2679,6 +2609,7 @@ +@@ -2680,6 +2610,7 @@ if (j != 0) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch index ee4979668d..75ee568c8e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch @@ -8,7 +8,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -@@ -91,11 +92,14 @@ +@@ -98,11 +99,14 @@ public void func_110571_b(IResourceManager p_110571_1_) { @@ -20,10 +20,10 @@ this.field_94258_i.clear(); int j = Integer.MAX_VALUE; + ForgeHooksClient.onTextureStitchedPre(this); - cpw.mods.fml.common.ProgressManager.ProgressBar bar = cpw.mods.fml.common.ProgressManager.push("Texture stitching", this.field_110574_e.size()); + cpw.mods.fml.common.ProgressManager.ProgressBar bar = cpw.mods.fml.common.ProgressManager.push("Texture Loading", skipFirst ? 0 : this.field_110574_e.size()); Iterator iterator = this.field_110574_e.entrySet().iterator(); TextureAtlasSprite textureatlassprite; -@@ -108,6 +112,16 @@ +@@ -115,6 +119,16 @@ ResourceLocation resourcelocation1 = this.func_147634_a(resourcelocation, 0); bar.step(resourcelocation1.func_110623_a()); @@ -40,7 +40,7 @@ try { IResource iresource = p_110571_1_.func_110536_a(resourcelocation1); -@@ -286,6 +300,7 @@ +@@ -294,6 +308,7 @@ textureatlassprite = (TextureAtlasSprite)iterator2.next(); textureatlassprite.func_94217_a(this.field_94249_f); } @@ -48,7 +48,7 @@ cpw.mods.fml.common.ProgressManager.pop(bar); } -@@ -360,7 +375,7 @@ +@@ -368,7 +383,7 @@ { throw new IllegalArgumentException("Name cannot be null!"); } @@ -57,7 +57,7 @@ { Object object = (TextureAtlasSprite)this.field_110574_e.get(p_94245_1_); -@@ -416,4 +431,37 @@ +@@ -424,4 +439,37 @@ { this.field_147637_k = p_147632_1_; } From e5192788887d7e334a7200e0e6e5342439619f3e Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Thu, 18 Jun 2015 22:17:21 -0700 Subject: [PATCH 7/9] Add TextureManager to loading screen. --- .../renderer/texture/TextureManager.java.patch | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 fml/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch diff --git a/fml/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch b/fml/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch new file mode 100644 index 0000000000..364d0cd62f --- /dev/null +++ b/fml/patches/minecraft/net/minecraft/client/renderer/texture/TextureManager.java.patch @@ -0,0 +1,18 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/texture/TextureManager.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/texture/TextureManager.java +@@ -162,12 +162,15 @@ + + public void func_110549_a(IResourceManager p_110549_1_) + { ++ cpw.mods.fml.common.ProgressManager.ProgressBar bar = cpw.mods.fml.common.ProgressManager.push("Reloading Texture Manager", this.field_110585_a.keySet().size(), true); + Iterator iterator = this.field_110585_a.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); ++ bar.step(entry.getKey().toString()); + this.func_110579_a((ResourceLocation)entry.getKey(), (ITextureObject)entry.getValue()); + } ++ cpw.mods.fml.common.ProgressManager.pop(bar); + } + } From 7041fbc27ea2fab17ed48fb6abc6340334962077 Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Thu, 18 Jun 2015 22:18:27 -0700 Subject: [PATCH 8/9] Time each bar in the loading screen and print it to the log, useful information to see where most time is spent in loading. --- .../net/minecraft/client/Minecraft.java.patch | 2 +- ...SimpleReloadableResourceManager.java.patch | 2 +- .../cpw/mods/fml/client/SplashProgress.java | 4 +- .../cpw/mods/fml/common/LoadController.java | 2 +- .../cpw/mods/fml/common/ProgressManager.java | 38 ++++++++++++++++++- 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 22438e2524..5702cca74d 100644 --- a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -64,7 +64,7 @@ this.field_110451_am.func_110542_a(this.field_71464_q); this.field_110451_am.func_110542_a(new GrassColorReloadListener()); this.field_110451_am.func_110542_a(new FoliageColorReloadListener()); -+ cpw.mods.fml.common.ProgressManager.ProgressBar bar= cpw.mods.fml.common.ProgressManager.push("Rendering Setup", 9); ++ cpw.mods.fml.common.ProgressManager.ProgressBar bar= cpw.mods.fml.common.ProgressManager.push("Rendering Setup", 9, true); + bar.step("Loading Render Manager"); RenderManager.field_78727_a.field_78721_f = new ItemRenderer(this); + bar.step("Loading Entity Renderer"); diff --git a/fml/patches/minecraft/net/minecraft/client/resources/SimpleReloadableResourceManager.java.patch b/fml/patches/minecraft/net/minecraft/client/resources/SimpleReloadableResourceManager.java.patch index 73705f504b..b2b7984051 100644 --- a/fml/patches/minecraft/net/minecraft/client/resources/SimpleReloadableResourceManager.java.patch +++ b/fml/patches/minecraft/net/minecraft/client/resources/SimpleReloadableResourceManager.java.patch @@ -4,7 +4,7 @@ public void func_110541_a(List p_110541_1_) { this.func_110543_a(); -+ cpw.mods.fml.common.ProgressManager.ProgressBar resReload = cpw.mods.fml.common.ProgressManager.push("Loading Resources", p_110541_1_.size()+1); ++ cpw.mods.fml.common.ProgressManager.ProgressBar resReload = cpw.mods.fml.common.ProgressManager.push("Loading Resources", p_110541_1_.size()+1, true); field_147967_a.info("Reloading ResourceManager: " + field_130074_a.join(Iterables.transform(p_110541_1_, new Function() { private static final String __OBFID = "CL_00001092"; diff --git a/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java b/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java index ac27436b1a..d61e08650d 100644 --- a/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java +++ b/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java @@ -363,7 +363,7 @@ public class SplashProgress drawBox(barWidth - 2, barHeight - 2); // slidy part setColor(barColor); - drawBox((barWidth - 2) * b.getStep() / b.getSteps(), barHeight - 2); + drawBox((barWidth - 2) * (b.getStep() + 1) / (b.getSteps() + 1), barHeight - 2); // Step can sometimes be 0. // progress text String progress = "" + b.getStep() + "/" + b.getSteps(); glTranslatef(((float)barWidth - 2) / 2 - fontRenderer.getStringWidth(progress), 2, 0); @@ -766,4 +766,4 @@ public class SplashProgress } return mcPack.getInputStream(loc); } -} +} \ No newline at end of file diff --git a/fml/src/main/java/cpw/mods/fml/common/LoadController.java b/fml/src/main/java/cpw/mods/fml/common/LoadController.java index 3c4802a7f5..eb5d0548e7 100644 --- a/fml/src/main/java/cpw/mods/fml/common/LoadController.java +++ b/fml/src/main/java/cpw/mods/fml/common/LoadController.java @@ -183,7 +183,7 @@ public class LoadController { modObjectList = buildModObjectList(); } - ProgressBar bar = ProgressManager.push(stateEvent.description(), activeModList.size()); + ProgressBar bar = ProgressManager.push(stateEvent.description(), activeModList.size(), true); for (ModContainer mc : activeModList) { bar.step(mc.getName()); diff --git a/fml/src/main/java/cpw/mods/fml/common/ProgressManager.java b/fml/src/main/java/cpw/mods/fml/common/ProgressManager.java index 7808c3d201..9706304de3 100644 --- a/fml/src/main/java/cpw/mods/fml/common/ProgressManager.java +++ b/fml/src/main/java/cpw/mods/fml/common/ProgressManager.java @@ -19,9 +19,21 @@ public class ProgressManager */ @Deprecated public static ProgressBar push(String title, int steps) + { + return push(title, steps, false); + } + /** + * @deprecated not a stable API, will break, don't use this yet + */ + @Deprecated + public static ProgressBar push(String title, int steps, boolean timeEachStep) { ProgressBar bar = new ProgressBar(title, steps); bars.add(bar); + if (timeEachStep) + { + bar.timeEachStep(); + } FMLCommonHandler.instance().processWindowMessages(); return bar; } @@ -34,6 +46,16 @@ public class ProgressManager { if(bar.getSteps() != bar.getStep()) throw new IllegalStateException("can't pop unfinished ProgressBar " + bar.getTitle()); bars.remove(bar); + if (bar.getSteps() != 0) + { + long newTime = System.nanoTime(); + if (bar.timeEachStep) + FMLLog.fine("Bar Step: %s - %s took %.3fs", bar.getTitle(), bar.getMessage(), ((float)(newTime - bar.lastTime) / 1000000 / 1000)); + if (bar.getSteps() == 1) + FMLLog.fine("Bar Finished: %s - %s took %.3fs", bar.getTitle(), bar.getMessage(), ((float)(newTime - bar.startTime) / 1000000 / 1000)); + else + FMLLog.fine("Bar Finished: %s took %.3fs", bar.getTitle(), ((float)(newTime - bar.startTime) / 1000000 / 1000)); + } FMLCommonHandler.instance().processWindowMessages(); } @@ -55,6 +77,9 @@ public class ProgressManager private final int steps; private volatile int step = 0; private volatile String message = ""; + private boolean timeEachStep = false; + private long startTime = System.nanoTime(); + private long lastTime = startTime; private ProgressBar(String title, int steps) { @@ -70,6 +95,12 @@ public class ProgressManager public void step(String message) { if(step >= steps) throw new IllegalStateException("too much steps for ProgressBar " + title); + if (timeEachStep && step != 0) + { + long newTime = System.nanoTime(); + FMLLog.fine("Bar Step: %s - %s took %.3fs", getTitle(), getMessage(), ((float)(newTime - lastTime) / 1000000 / 1000)); + lastTime = newTime; + } step++; this.message = FMLCommonHandler.instance().stripSpecialChars(message); FMLCommonHandler.instance().processWindowMessages(); @@ -94,5 +125,10 @@ public class ProgressManager { return message; } + + public void timeEachStep() + { + this.timeEachStep = true; + } } -} +} \ No newline at end of file From 2c24c7618a50d74c4626441adeb4e30c9e2cffb0 Mon Sep 17 00:00:00 2001 From: cpw Date: Sat, 20 Jun 2015 14:47:55 -0400 Subject: [PATCH 9/9] Mods that are extracted to the mods dir by unzipping or whatever will now cause the game to crash. Too much info is in the META-INF now, and more will be being added. Extracting to the mods dir just completely breaks that. --- fml/jsons/1.7.10-dev.json | 2 +- fml/jsons/1.7.10-rel.json | 2 +- .../mods/fml/relauncher/CoreModManager.java | 43 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/fml/jsons/1.7.10-dev.json b/fml/jsons/1.7.10-dev.json index 02ab3de1e3..e5e56d57ec 100644 --- a/fml/jsons/1.7.10-dev.json +++ b/fml/jsons/1.7.10-dev.json @@ -8,7 +8,7 @@ "assets": "1.7.10", "libraries": [ { - "name": "net.minecraft:launchwrapper:1.11" + "name": "net.minecraft:launchwrapper:1.12" }, { "name": "com.google.code.findbugs:jsr305:1.3.9", diff --git a/fml/jsons/1.7.10-rel.json b/fml/jsons/1.7.10-rel.json index a13bfc3ff2..0f44d2693e 100644 --- a/fml/jsons/1.7.10-rel.json +++ b/fml/jsons/1.7.10-rel.json @@ -27,7 +27,7 @@ "url": "http://files.minecraftforge.net/maven/" }, { - "name": "net.minecraft:launchwrapper:1.11", + "name": "net.minecraft:launchwrapper:1.12", "serverreq":true }, { diff --git a/fml/src/main/java/cpw/mods/fml/relauncher/CoreModManager.java b/fml/src/main/java/cpw/mods/fml/relauncher/CoreModManager.java index 9231c71b49..0eb0701f24 100644 --- a/fml/src/main/java/cpw/mods/fml/relauncher/CoreModManager.java +++ b/fml/src/main/java/cpw/mods/fml/relauncher/CoreModManager.java @@ -13,24 +13,30 @@ package cpw.mods.fml.relauncher; import java.io.File; +import java.io.FileFilter; import java.io.FilenameFilter; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.jar.Attributes; import java.util.jar.JarFile; + import net.minecraft.launchwrapper.ITweaker; import net.minecraft.launchwrapper.Launch; import net.minecraft.launchwrapper.LaunchClassLoader; + import org.apache.logging.log4j.Level; + import com.google.common.base.Strings; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; @@ -38,6 +44,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.ObjectArrays; import com.google.common.primitives.Ints; + import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.asm.transformers.ModAccessTransformer; import cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker; @@ -243,6 +250,42 @@ public class CoreModManager { FMLRelaunchLog.severe("Problem file : %s", f.getName()); } } + FileFilter derpdirfilter = new FileFilter() { + @Override + public boolean accept(File pathname) + { + return pathname.isDirectory() && new File(pathname,"META-INF").isDirectory(); + } + + }; + File[] derpdirlist = coreMods.listFiles(derpdirfilter); + if (derpdirlist != null && derpdirlist.length > 0) + { + FMLRelaunchLog.log.getLogger().log(Level.FATAL, "There appear to be jars extracted into the mods directory. This is VERY BAD and will almost NEVER WORK WELL"); + FMLRelaunchLog.log.getLogger().log(Level.FATAL, "You should place original jars only in the mods directory. NEVER extract them to the mods directory."); + FMLRelaunchLog.log.getLogger().log(Level.FATAL, "The directories below appear to be extracted jar files. Fix this before you continue."); + + for (File f : derpdirlist) + { + FMLRelaunchLog.log.getLogger().log(Level.FATAL, "Directory {} contains {}", f.getName(), Arrays.asList(new File(f,"META-INF").list())); + } + + RuntimeException re = new RuntimeException("Extracted mod jars found, loading will NOT continue"); + // We're generating a crash report for the launcher to show to the user here + try + { + Class crashreportclass = classLoader.loadClass("b"); + Object crashreport = crashreportclass.getMethod("a", Throwable.class, String.class).invoke(null, re, "FML has discovered extracted jar files in the mods directory.\nThis breaks mod loading functionality completely.\nRemove the directories and replace with the jar files originally provided."); + File crashreportfile = new File(new File(coreMods.getParentFile(),"crash-reports"),String.format("fml-crash-%1$tY-%1$tm-%1$td_%1$tT.txt",Calendar.getInstance())); + crashreportclass.getMethod("a",File.class).invoke(crashreport, crashreportfile); + System.out.println("#@!@# FML has crashed the game deliberately. Crash report saved to: #@!@# " + crashreportfile.getAbsolutePath()); + } catch (Exception e) + { + e.printStackTrace(); + // NOOP - hopefully + } + throw re; + } File[] coreModList = coreMods.listFiles(ff); File versionedModDir = new File(coreMods, FMLInjectionData.mccversion); if (versionedModDir.isDirectory())