Skip to content

Commit

Permalink
#1298 - Fixed content packs not loading on CurseForge
Browse files Browse the repository at this point in the history
  • Loading branch information
jamioflan committed Oct 6, 2020
1 parent 24a3b24 commit 9658480
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ minecraft_version = 1.12.2
version_major = 5
version_minor = 6
version_patch = 0
version_extra = -beta.8
version_extra = -beta.9
5 changes: 3 additions & 2 deletions src/main/java/com/flansmod/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.resource.VanillaResourceType;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.client.FMLClientHandler;
Expand Down Expand Up @@ -223,8 +224,8 @@ public void registerModels(ModelRegistryEvent event)
*/
@Override
public void forceReload()
{
Minecraft.getMinecraft().refreshResources();
{
FMLClientHandler.instance().refreshResources(VanillaResourceType.MODELS, VanillaResourceType.TEXTURES, VanillaResourceType.SOUNDS, VanillaResourceType.LANGUAGES);
}

/**
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/flansmod/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,35 @@
import com.flansmod.common.teams.ArmourBoxType;
import com.flansmod.common.types.EnumType;
import com.flansmod.common.types.InfoType;
import com.google.common.io.Files;

public class CommonProxy
{
protected static Pattern zipJar = Pattern.compile("(.+).(zip|jar)$");

public void CopyContentPacksFromModsFolder()
{
for(File file : FlansMod.modDir.listFiles())
{
if(file.isDirectory() || zipJar.matcher(file.getName()).matches())
{
if(file.getName().contains("Content Pack"))
{
try
{
Files.copy(file, new File(FlansMod.flanDir + "/" + file.getName()));
}
catch(Exception e)
{
FlansMod.log.error("Failed to copy content pack to Flan folder : " + file.getName());
FlansMod.log.throwing(e);
}
}

}
}
}

/**
* Returns the list of content pack files, and on the client, adds the content pack resources and models to the classpath
*/
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/flansmod/common/FlansMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public class FlansMod
//A standardised ticker for all bits of the mod to call upon if they need one
public static int ticker = 0;
public static long lastTime;
public static File flanDir;
public static File flanDir, modDir;
public static final float soundRange = 50F;
public static final float driveableUpdateRange = 200F;
public static final int numPlayerSnapshots = 20;
Expand Down Expand Up @@ -222,6 +222,7 @@ public void preInit(FMLPreInitializationEvent event)
isApocalypseLoaded = false;
}

modDir = new File(event.getModConfigurationDirectory().getParentFile(), "/mods/");
flanDir = new File(event.getModConfigurationDirectory().getParentFile(), "/Flan/");

if(!flanDir.exists())
Expand Down Expand Up @@ -640,6 +641,8 @@ private void readContentPacks(FMLPreInitializationEvent event)
FlansMod.log.throwing(e);
}


proxy.CopyContentPacksFromModsFolder();
List<File> contentPacks = proxy.getContentList(method, classloader);

//TODO : Add gametype loader
Expand Down

0 comments on commit 9658480

Please sign in to comment.