Mods are now loaded as resource packs. Vanilla will scan for valid prefixes based on subdirs of 'assets' which

can then be referenced as ResourceLocations with the "<prefix>:path" notation.
This commit is contained in:
Christian 2013-07-02 01:39:40 -04:00
parent f978e6b50e
commit 76a1489d4b
5 changed files with 39 additions and 2 deletions

View File

@ -12,6 +12,7 @@
*/
package cpw.mods.fml.client;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -28,6 +29,9 @@ import net.minecraft.client.multiplayer.NetClientHandler;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.resources.FileResourcePack;
import net.minecraft.client.resources.FolderResourcePack;
import net.minecraft.client.resources.ResourcePack;
import net.minecraft.crash.CrashReport;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
@ -126,14 +130,18 @@ public class FMLClientHandler implements IFMLSidedHandler
private boolean serverShouldBeKilledQuietly;
private List<ResourcePack> resourcePackList;
/**
* Called to start the whole game off
*
* @param minecraft The minecraft instance being launched
* @param field_110449_ao
*/
public void beginMinecraftLoading(Minecraft minecraft)
public void beginMinecraftLoading(Minecraft minecraft, List resourcePackList)
{
client = minecraft;
this.resourcePackList = resourcePackList;
if (minecraft.func_71355_q())
{
FMLLog.severe("DEMO MODE DETECTED, FML will not work. Finishing now.");
@ -550,4 +558,19 @@ public class FMLClientHandler implements IFMLSidedHandler
{
return client.field_71462_r != null && client.field_71462_r.getClass().equals(gui);
}
@Override
public void addModAsResource(ModContainer container)
{
File modSource = container.getSource();
if (modSource.isFile())
{
resourcePackList.add(new FileResourcePack(modSource));
}
else if (modSource.isDirectory())
{
resourcePackList.add(new FolderResourcePack(modSource));
}
}
}

View File

@ -486,4 +486,9 @@ public class FMLCommonHandler
}
return Joiner.on(',').join(modNames);
}
public void addModToResourcePack(ModContainer container)
{
sidedDelegate.addModAsResource(container);
}
}

View File

@ -5,7 +5,7 @@
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*
* Contributors:
* cpw - implementation
*/
@ -62,4 +62,6 @@ public interface IFMLSidedHandler
boolean shouldServerShouldBeKilledQuietly();
void disconnectIDMismatch(MapDifference<Integer, ItemData> s, NetHandler toKill, INetworkManager mgr);
void addModAsResource(ModContainer container);
}

View File

@ -84,6 +84,7 @@ public class LoadController
activeModList.add(mod);
modStates.put(mod.getModId(), ModState.UNLOADED);
eventBus.put(mod.getModId(), bus);
FMLCommonHandler.instance().addModToResourcePack(mod);
}
else
{

View File

@ -27,6 +27,7 @@ import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.IFMLSidedHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.common.network.EntitySpawnAdjustmentPacket;
import cpw.mods.fml.common.network.EntitySpawnPacket;
@ -189,4 +190,9 @@ public class FMLServerHandler implements IFMLSidedHandler
{
}
@Override
public void addModAsResource(ModContainer container)
{
// NOOP on server
}
}