Fix localizations not loading correctly in legacy resource packs.

This commit is contained in:
LexManos 2016-11-15 22:59:31 -08:00
parent 41916ae39a
commit f8cba13b5b
4 changed files with 18 additions and 4 deletions

View file

@ -13,7 +13,7 @@
this.field_135017_as = new LanguageManager(this.field_110452_an, this.field_71474_y.field_74363_ab); this.field_135017_as = new LanguageManager(this.field_110452_an, this.field_71474_y.field_74363_ab);
this.field_110451_am.func_110542_a(this.field_135017_as); this.field_110451_am.func_110542_a(this.field_135017_as);
- this.func_110436_a(); - this.func_110436_a();
+ net.minecraftforge.fml.client.FMLClientHandler.instance().beginMinecraftLoading(this, this.field_110449_ao, this.field_110451_am); + net.minecraftforge.fml.client.FMLClientHandler.instance().beginMinecraftLoading(this, this.field_110449_ao, this.field_110451_am, this.field_110452_an);
this.field_71446_o = new TextureManager(this.field_110451_am); this.field_71446_o = new TextureManager(this.field_110451_am);
this.field_110451_am.func_110542_a(this.field_71446_o); this.field_110451_am.func_110542_a(this.field_71446_o);
- this.func_180510_a(this.field_71446_o); - this.func_180510_a(this.field_71446_o);

View file

@ -52,7 +52,10 @@ import net.minecraft.client.resources.AbstractResourcePack;
import net.minecraft.client.resources.FallbackResourceManager; import net.minecraft.client.resources.FallbackResourceManager;
import net.minecraft.client.resources.IReloadableResourceManager; import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourcePack; import net.minecraft.client.resources.IResourcePack;
import net.minecraft.client.resources.LegacyV2Adapter;
import net.minecraft.client.resources.SimpleReloadableResourceManager; import net.minecraft.client.resources.SimpleReloadableResourceManager;
import net.minecraft.client.resources.data.MetadataSerializer;
import net.minecraft.client.resources.data.PackMetadataSection;
import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReport;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.launchwrapper.Launch; import net.minecraft.launchwrapper.Launch;
@ -181,6 +184,8 @@ public class FMLClientHandler implements IFMLSidedHandler
private List<IResourcePack> resourcePackList; private List<IResourcePack> resourcePackList;
private MetadataSerializer metaSerializer;
private Map<String, IResourcePack> resourcePackMap; private Map<String, IResourcePack> resourcePackMap;
private BiMap<ModContainer, IModGuiFactory> guiFactories; private BiMap<ModContainer, IModGuiFactory> guiFactories;
@ -198,12 +203,13 @@ public class FMLClientHandler implements IFMLSidedHandler
* @param resourceManager The resource manager * @param resourceManager The resource manager
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void beginMinecraftLoading(Minecraft minecraft, List<IResourcePack> resourcePackList, IReloadableResourceManager resourceManager) public void beginMinecraftLoading(Minecraft minecraft, List<IResourcePack> resourcePackList, IReloadableResourceManager resourceManager, MetadataSerializer metaSerializer)
{ {
detectOptifine(); detectOptifine();
SplashProgress.start(); SplashProgress.start();
client = minecraft; client = minecraft;
this.resourcePackList = resourcePackList; this.resourcePackList = resourcePackList;
this.metaSerializer = metaSerializer;
this.resourcePackMap = Maps.newHashMap(); this.resourcePackMap = Maps.newHashMap();
if (minecraft.isDemo()) if (minecraft.isDemo())
{ {
@ -623,6 +629,14 @@ public class FMLClientHandler implements IFMLSidedHandler
try try
{ {
IResourcePack pack = (IResourcePack) resourcePackType.getConstructor(ModContainer.class).newInstance(container); IResourcePack pack = (IResourcePack) resourcePackType.getConstructor(ModContainer.class).newInstance(container);
PackMetadataSection meta = (PackMetadataSection)pack.getPackMetadata(this.metaSerializer, "pack");
if (meta != null && meta.getPackFormat() == 2)
{
pack = new LegacyV2Adapter(pack);
}
resourcePackList.add(pack); resourcePackList.add(pack);
resourcePackMap.put(container.getModId(), pack); resourcePackMap.put(container.getModId(), pack);
} }

View file

@ -65,7 +65,7 @@ public class FMLFileResourcePack extends FileResourcePack implements FMLContaine
return new ByteArrayInputStream(("{\n" + return new ByteArrayInputStream(("{\n" +
" \"pack\": {\n"+ " \"pack\": {\n"+
" \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+ " \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+
" \"pack_format\": 1\n"+ " \"pack_format\": 2\n"+
"}\n" + "}\n" +
"}").getBytes(Charsets.UTF_8)); "}").getBytes(Charsets.UTF_8));
} }

View file

@ -70,7 +70,7 @@ public class FMLFolderResourcePack extends FolderResourcePack implements FMLCont
return new ByteArrayInputStream(("{\n" + return new ByteArrayInputStream(("{\n" +
" \"pack\": {\n"+ " \"pack\": {\n"+
" \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+ " \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+
" \"pack_format\": 1\n"+ " \"pack_format\": 2\n"+
"}\n" + "}\n" +
"}").getBytes(Charsets.UTF_8)); "}").getBytes(Charsets.UTF_8));
} }