Resources now only install client-side, added the workaround for the level-type BIOMESOP being broken in SMP

This commit is contained in:
Adubbz 2013-04-06 19:34:17 +11:00
parent bd18ea4a78
commit 872b13a632
2 changed files with 41 additions and 24 deletions

View File

@ -6,6 +6,9 @@ import static net.minecraftforge.common.Configuration.CATEGORY_GENERAL;
import java.io.File; import java.io.File;
import java.util.logging.Level; import java.util.logging.Level;
import tdwp_ftw.biomesop.ClientProxy;
import tdwp_ftw.biomesop.mod_BiomesOPlenty;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
@ -415,6 +418,8 @@ public class BOPConfiguration {
public static void init(File configFile) public static void init(File configFile)
{ {
boolean isClient = mod_BiomesOPlenty.proxy instanceof ClientProxy;
config = new Configuration(configFile); config = new Configuration(configFile);
try try
@ -424,9 +429,17 @@ public class BOPConfiguration {
skyColors = true; skyColors = true;
biomeSize = config.get("Biome Settings", "Biome Size", 4, null).getInt(); biomeSize = config.get("Biome Settings", "Biome Size", 4, null).getInt();
achievements = config.get("Achievement Settings", "Add Biomes O Plenty Achievemnets (Currently Broken)", false).getBoolean(false); achievements = config.get("Achievement Settings", "Add Biomes O Plenty Achievemnets (Currently Broken)", false).getBoolean(false);
addToDefault = config.get("Biome Settings", "Add Biomes To Default World", false).getBoolean(false);
vanillaEnhanced = config.get("Biome Settings", "Enhanced Vanilla Biomes", true).getBoolean(false); vanillaEnhanced = config.get("Biome Settings", "Enhanced Vanilla Biomes", true).getBoolean(false);
promisedLandDimID = config.get("Dimension Settings", "Promised Land Dimension ID", 20, null).getInt(); promisedLandDimID = config.get("Dimension Settings", "Promised Land Dimension ID", 20, null).getInt();
if (!isClient)
{
addToDefault = config.get("Biome Settings", "Add Biomes To Default World", true).getBoolean(true);
}
else
{
addToDefault = config.get("Biome Settings", "Add Biomes To Default World", false).getBoolean(false);
}
alpsGen = config.get("Biomes To Generate", "Alps", true).getBoolean(false); alpsGen = config.get("Biomes To Generate", "Alps", true).getBoolean(false);
arcticGen = config.get("Biomes To Generate", "Arctic", true).getBoolean(false); arcticGen = config.get("Biomes To Generate", "Arctic", true).getBoolean(false);

View File

@ -74,34 +74,38 @@ public class mod_BiomesOPlenty
@PreInit @PreInit
public void preInit(FMLPreInitializationEvent event) public void preInit(FMLPreInitializationEvent event)
{ {
boolean isClient = proxy instanceof ClientProxy;
String[] soundFiles = { "bopdisc.ogg", "bopdiscmud.ogg"}; String[] soundFiles = { "bopdisc.ogg", "bopdiscmud.ogg"};
for (String soundFile : soundFiles) try if (isClient)
{ {
File file = new File("resources/mod/streaming/" + soundFile); for (String soundFile : soundFiles) try
if (!file.exists()) { {
System.out.println("[BoP] " + soundFile + " doesn't exist, creating..."); File file = new File("resources/mod/streaming/" + soundFile);
file.getParentFile().mkdirs(); if (!file.exists()) {
file.createNewFile(); System.out.println("[BoP] " + soundFile + " doesn't exist, creating...");
InputStream istream = getClass().getResourceAsStream("/mods/BiomesOPlenty/audio/" + soundFile); file.getParentFile().mkdirs();
OutputStream out = new FileOutputStream(file); file.createNewFile();
byte[] buf = new byte[1024]; InputStream istream = getClass().getResourceAsStream("/mods/BiomesOPlenty/audio/" + soundFile);
int size = 0; OutputStream out = new FileOutputStream(file);
int len; byte[] buf = new byte[1024];
while ((len = istream.read(buf)) > 0) { int size = 0;
out.write(buf, 0, len); int len;
size += len; while ((len = istream.read(buf)) > 0) {
out.write(buf, 0, len);
size += len;
}
out.close();
istream.close();
if (size == 0) file.delete();
} }
out.close();
istream.close();
if (size == 0) file.delete();
} }
} catch (Exception e)
catch (Exception e) {
{ FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, "[BoP] Failed to load sound file: " + soundFile);
FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, "[BoP] Failed to load sound file: " + soundFile); e.printStackTrace();
e.printStackTrace(); }
} }
BOPConfiguration.init(event.getSuggestedConfigurationFile()); BOPConfiguration.init(event.getSuggestedConfigurationFile());