summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-05-21 18:48:35 +0300
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-05-21 18:48:35 +0300
commit27b6d250ba6005bfa9cdd9d291e0656f5e02fa65 (patch)
tree89fd6b927e3cdd9391a2479cfa08dee2bda1c15e /src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
parent2b4aedb9fb90e02c8ec89130919fb9cfae82770c (diff)
Liquids!
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java')
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java58
1 files changed, 51 insertions, 7 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
index d8d49a2..957705c 100644
--- a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java
@@ -1,27 +1,31 @@
package darkknight.jewelrycraft.events;
+import java.io.EOFException;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.world.WorldServer;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.world.WorldEvent;
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import darkknight.jewelrycraft.JewelrycraftMod;
import darkknight.jewelrycraft.item.ItemList;
import darkknight.jewelrycraft.util.BlockUtils;
import darkknight.jewelrycraft.util.PlayerUtils;
-import cpw.mods.fml.common.FMLCommonHandler;
-import cpw.mods.fml.common.eventhandler.SubscribeEvent;
/**
* Code taken from OpenBlocks
*/
+
public class EntityEventHandler
{
public static final String OPENBLOCKS_PERSIST_TAG = "Jewelrycraft";
@@ -31,10 +35,7 @@ public class EntityEventHandler
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
final Entity entity = event.entity;
- /**
- * If the player hasn't been given a manual, we'll give him one! (or
- * throw it on the floor..)
- */
+
if (!event.world.isRemote && entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer)entity;
@@ -52,4 +53,47 @@ public class EntityEventHandler
}
}
}
+
+ @SubscribeEvent
+ public void onWorldLoad(WorldEvent.Load event)
+ {
+ if(!event.world.isRemote)
+ {
+ JewelrycraftMod.liquidsConf = new File(JewelrycraftMod.dir, "JLP" + event.world.getWorldInfo().getWorldName() + ".cfg");
+ try {
+ if(!JewelrycraftMod.liquidsConf.exists()) JewelrycraftMod.liquidsConf.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if(FMLCommonHandler.instance().getEffectiveSide().isServer())
+ {
+ try {
+ if(JewelrycraftMod.liquidsConf.exists())
+ JewelrycraftMod.saveData = CompressedStreamTools.readCompressed(new FileInputStream(JewelrycraftMod.liquidsConf));
+ } catch (EOFException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ @SubscribeEvent
+ public void onWorldSave(WorldEvent.Save event)
+ {
+ if(FMLCommonHandler.instance().getEffectiveSide().isServer())
+ {
+ try {
+ if(JewelrycraftMod.liquidsConf.exists())
+ CompressedStreamTools.writeCompressed(JewelrycraftMod.saveData, new FileOutputStream(JewelrycraftMod.liquidsConf));
+ } catch (EOFException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
} \ No newline at end of file