Cleanup
This commit is contained in:
parent
603d95f7f0
commit
75cd937e61
7 changed files with 81 additions and 60 deletions
|
@ -19,14 +19,15 @@ import biomesoplenty.configuration.BOPItems;
|
|||
import biomesoplenty.configuration.BOPLiquids;
|
||||
import biomesoplenty.configuration.BOPPotions;
|
||||
import biomesoplenty.configuration.BOPVanillaCompat;
|
||||
import biomesoplenty.handlers.BOPCraftHandler;
|
||||
import biomesoplenty.handlers.BonemealHandler;
|
||||
import biomesoplenty.handlers.EntityEventHandler;
|
||||
import biomesoplenty.handlers.SoundHandler;
|
||||
import biomesoplenty.handlers.TickHandlerClient;
|
||||
import biomesoplenty.helpers.AchievementHelper;
|
||||
import biomesoplenty.helpers.BOPCraft;
|
||||
import biomesoplenty.helpers.BOPLiquidHelper;
|
||||
import biomesoplenty.helpers.BonemealUse;
|
||||
import biomesoplenty.helpers.CreativeTabsBOP;
|
||||
import biomesoplenty.helpers.EntitiesHelper;
|
||||
import biomesoplenty.helpers.Localizations;
|
||||
import biomesoplenty.helpers.TickHandlerClient;
|
||||
import biomesoplenty.helpers.Version;
|
||||
import biomesoplenty.integration.BOPCrossIntegration;
|
||||
import biomesoplenty.world.WorldProviderBOPhell;
|
||||
|
@ -64,64 +65,22 @@ public class BiomesOPlenty
|
|||
@PreInit
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
boolean isClient = proxy instanceof ClientProxy;
|
||||
|
||||
String[] soundFiles = { "bopdisc.ogg", "bopdiscmud.ogg"};
|
||||
|
||||
if (isClient)
|
||||
{
|
||||
for (String soundFile : soundFiles) {
|
||||
try
|
||||
{
|
||||
File file = new File(Minecraft.getMinecraftDir().getAbsolutePath() + "/resources/mod/streaming/" + soundFile);
|
||||
if (!file.exists()) {
|
||||
System.out.println("[BiomesOPlenty] " + soundFile + " doesn't exist, creating...");
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
InputStream istream = getClass().getResourceAsStream("/mods/BiomesOPlenty/audio/" + soundFile);
|
||||
OutputStream out = new FileOutputStream(file);
|
||||
byte[] buf = new byte[1024];
|
||||
int size = 0;
|
||||
int len;
|
||||
while ((len = istream.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
size += len;
|
||||
}
|
||||
out.close();
|
||||
istream.close();
|
||||
if (size == 0) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, "[BiomesOPlenty] Failed to load sound file: " + soundFile);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOPConfiguration.init(event.getSuggestedConfigurationFile());
|
||||
|
||||
SoundHandler soundHandler = new SoundHandler();
|
||||
soundHandler.installRecordTracks();
|
||||
|
||||
Version.check();
|
||||
|
||||
tabBiomesOPlenty = new CreativeTabsBOP(CreativeTabs.getNextID(),"tabBiomesOPlenty");
|
||||
|
||||
BOPPotions.init();
|
||||
|
||||
BOPBlocks.init();
|
||||
|
||||
BOPItems.init();
|
||||
|
||||
BOPLiquids.init();
|
||||
|
||||
BOPCrafting.init();
|
||||
|
||||
BOPBiomes.init();
|
||||
|
||||
BOPEntities.init();
|
||||
|
||||
BOPVanillaCompat.init();
|
||||
|
||||
Localizations.loadLanguages();
|
||||
|
@ -132,7 +91,7 @@ public class BiomesOPlenty
|
|||
AchievementHelper.init();
|
||||
}
|
||||
|
||||
GameRegistry.registerCraftingHandler(new BOPCraft());
|
||||
GameRegistry.registerCraftingHandler(new BOPCraftHandler());
|
||||
}
|
||||
|
||||
@Init
|
||||
|
@ -144,8 +103,8 @@ public class BiomesOPlenty
|
|||
// Add helpers for compatibility
|
||||
MinecraftForge.TERRAIN_GEN_BUS.register(new WorldTypeSize());
|
||||
MinecraftForge.EVENT_BUS.register(new AchievementHelper());
|
||||
MinecraftForge.EVENT_BUS.register(new BonemealUse());
|
||||
MinecraftForge.EVENT_BUS.register(new EntitiesHelper());
|
||||
MinecraftForge.EVENT_BUS.register(new BonemealHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new EntityEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new BOPLiquidHelper());
|
||||
|
||||
proxy.registerRenderers();
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package biomesoplenty.helpers;
|
||||
package biomesoplenty.handlers;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import biomesoplenty.api.Items;
|
||||
import biomesoplenty.configuration.BOPConfiguration;
|
||||
import biomesoplenty.helpers.AchievementHelper;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
|
||||
public class BOPCraft implements ICraftingHandler
|
||||
public class BOPCraftHandler implements ICraftingHandler
|
||||
{
|
||||
@Override
|
||||
public void onCrafting(EntityPlayer var1, ItemStack var2, IInventory var3)
|
|
@ -1,4 +1,4 @@
|
|||
package biomesoplenty.helpers;
|
||||
package biomesoplenty.handlers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.event.Event.Result;
|
||||
|
@ -10,7 +10,7 @@ import biomesoplenty.blocks.BlockBOPSapling;
|
|||
import biomesoplenty.worldgen.WorldGenGiantFlowerRed;
|
||||
import biomesoplenty.worldgen.WorldGenGiantFlowerYellow;
|
||||
|
||||
public class BonemealUse
|
||||
public class BonemealHandler
|
||||
{
|
||||
|
||||
@ForgeSubscribe
|
|
@ -1,4 +1,4 @@
|
|||
package biomesoplenty.helpers;
|
||||
package biomesoplenty.handlers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -25,8 +25,9 @@ import biomesoplenty.api.Blocks;
|
|||
import biomesoplenty.api.Items;
|
||||
import biomesoplenty.configuration.BOPConfiguration;
|
||||
import biomesoplenty.entities.ai.EntityAITemptArmour;
|
||||
import biomesoplenty.helpers.TeleporterPromised;
|
||||
|
||||
public class EntitiesHelper
|
||||
public class EntityEventHandler
|
||||
{
|
||||
@ForgeSubscribe
|
||||
public void onEntitySpawn(EntityJoinWorldEvent event)
|
58
src/minecraft/biomesoplenty/handlers/SoundHandler.java
Normal file
58
src/minecraft/biomesoplenty/handlers/SoundHandler.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package biomesoplenty.handlers;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import biomesoplenty.BiomesOPlenty;
|
||||
import biomesoplenty.ClientProxy;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class SoundHandler
|
||||
{
|
||||
static String[] soundFiles = { "bopdisc.ogg", "bopdiscmud.ogg"};
|
||||
|
||||
public void installRecordTracks()
|
||||
{
|
||||
boolean isClient = BiomesOPlenty.proxy instanceof ClientProxy;
|
||||
|
||||
if (isClient)
|
||||
{
|
||||
for (String soundFile : soundFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
File file = new File(Minecraft.getMinecraftDir().getAbsolutePath() + "/resources/mod/streaming/" + soundFile);
|
||||
if (!file.exists()) {
|
||||
System.out.println("[BiomesOPlenty] " + soundFile + " doesn't exist, creating...");
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
InputStream istream = getClass().getResourceAsStream("/mods/BiomesOPlenty/audio/" + soundFile);
|
||||
OutputStream out = new FileOutputStream(file);
|
||||
byte[] buf = new byte[1024];
|
||||
int size = 0;
|
||||
int len;
|
||||
while ((len = istream.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
size += len;
|
||||
}
|
||||
out.close();
|
||||
istream.close();
|
||||
if (size == 0) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, "[BiomesOPlenty] Failed to load sound file: " + soundFile);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package biomesoplenty.helpers;
|
||||
package biomesoplenty.handlers;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import biomesoplenty.helpers.Version;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
|
@ -26,7 +26,7 @@ public class AchievementHelper
|
|||
private static Achievement achShroom;
|
||||
private static Achievement achBarley;
|
||||
private static Achievement achMoss;
|
||||
static Achievement achFlowerP;
|
||||
public static Achievement achFlowerP;
|
||||
|
||||
public static AchievementPage pageBOP;
|
||||
|
||||
|
|
Loading…
Reference in a new issue