From 76a1489d4b65d9c54f228cdbf401daf420656192 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 2 Jul 2013 01:39:40 -0400 Subject: [PATCH] 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 ":path" notation. --- .../cpw/mods/fml/client/FMLClientHandler.java | 25 ++++++++++++++++++- .../cpw/mods/fml/common/FMLCommonHandler.java | 5 ++++ .../cpw/mods/fml/common/IFMLSidedHandler.java | 4 ++- .../cpw/mods/fml/common/LoadController.java | 1 + .../cpw/mods/fml/server/FMLServerHandler.java | 6 +++++ 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java index 09b25d4f8..c810f434b 100644 --- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java +++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java @@ -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 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)); + } + } } diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java index 0bff1eedb..445c3076c 100644 --- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java @@ -486,4 +486,9 @@ public class FMLCommonHandler } return Joiner.on(',').join(modNames); } + + public void addModToResourcePack(ModContainer container) + { + sidedDelegate.addModAsResource(container); + } } diff --git a/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java b/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java index 2d7bcc9a5..a9ba216d1 100644 --- a/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java +++ b/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java @@ -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 s, NetHandler toKill, INetworkManager mgr); + + void addModAsResource(ModContainer container); } diff --git a/fml/common/cpw/mods/fml/common/LoadController.java b/fml/common/cpw/mods/fml/common/LoadController.java index 1fdb3a2bf..cc681db6b 100644 --- a/fml/common/cpw/mods/fml/common/LoadController.java +++ b/fml/common/cpw/mods/fml/common/LoadController.java @@ -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 { diff --git a/fml/common/cpw/mods/fml/server/FMLServerHandler.java b/fml/common/cpw/mods/fml/server/FMLServerHandler.java index 131064e23..e4ecec606 100644 --- a/fml/common/cpw/mods/fml/server/FMLServerHandler.java +++ b/fml/common/cpw/mods/fml/server/FMLServerHandler.java @@ -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 + } }