package joshie.harvestmoon.handlers.events;

import static joshie.harvestmoon.HarvestMoon.handler;
import static joshie.harvestmoon.helpers.CalendarHelper.getSeason;
import joshie.harvestmoon.blocks.BlockFlower;
import joshie.harvestmoon.blocks.items.ItemBlockFlower;
import joshie.harvestmoon.calendar.Season;
import joshie.harvestmoon.entities.EntityNPC;
import joshie.harvestmoon.handlers.ServerHandler;
import joshie.harvestmoon.init.HMNPCs;
import net.minecraft.client.gui.GuiMultiplayer;
import net.minecraft.client.gui.GuiSelectWorld;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.event.entity.item.ItemExpireEvent;
import net.minecraftforge.event.terraingen.BiomeEvent.GetFoliageColor;
import net.minecraftforge.event.world.WorldEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class GeneralEvents {
    @SubscribeEvent
    public void onItemExpire(ItemExpireEvent event) {
        World world = event.entityItem.worldObj;
        if (!world.isRemote) {
            if (event.entityItem.isInWater()) {
                ItemStack stack = event.entityItem.getEntityItem();
                if (stack != null) {
                    if (stack.getItem() instanceof ItemBlockFlower) {
                        if (stack.getItemDamage() == BlockFlower.GODDESS) {
                            EntityNPC goddess = HMNPCs.goddess.getEntity(world, (int) event.entityItem.posX, (int) event.entityItem.posY, (int) event.entityItem.posZ);
                            goddess.setPosition((int) event.entityItem.posX, (int) event.entityItem.posY, (int) event.entityItem.posZ);
                            world.spawnEntityInWorld(goddess);
                        }
                    }
                }
            }
        }
    }

    @SubscribeEvent
    public void onLoad(WorldEvent.Load event) {
        if (event.world.provider.dimensionId == 0) {
            if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
                handler.setServer(new ServerHandler(event.world));
            }
        }
    }

    @SideOnly(Side.CLIENT)
    @SubscribeEvent
    public void onOpenGUI(GuiOpenEvent event) {
        if (event.gui instanceof GuiSelectWorld || event.gui instanceof GuiMultiplayer) {
            handler.resetClient();
        }
    }

    @SubscribeEvent
    public void getFoliageColor(GetFoliageColor event) {
        if (getSeason() == Season.AUTUMN) {
            event.newColor = 0xFF9900;
        }
    }
}

@@ -439,16 +439,62 @@
 HMNPCs;%0A
+import net.minecraft.block.material.Material;%0A
 import n
@@ -1291,14 +1291,37 @@
 isIn
-Water(
+sideOfMaterial(Material.water
 )) %7B
@@ -1836,32 +1836,36 @@
 .entityItem.posY
+ + 1
 , (int) event.en

Fix water check.