2013-02-17 21:46:16 -05:00
package StevenDimDoors.mod_pocketDim ;
2013-06-13 19:01:54 -04:00
2013-02-17 21:46:16 -05:00
import net.minecraft.world.World ;
2013-03-22 00:58:55 -04:00
import net.minecraftforge.client.event.sound.SoundLoadEvent ;
2013-02-17 21:46:16 -05:00
import net.minecraftforge.event.ForgeSubscribe ;
import net.minecraftforge.event.entity.living.LivingFallEvent ;
import net.minecraftforge.event.entity.player.PlayerDropsEvent ;
import net.minecraftforge.event.world.WorldEvent ;
2013-07-25 00:12:13 -04:00
import StevenDimDoors.mod_pocketDim.helpers.dimHelper ;
import cpw.mods.fml.relauncher.Side ;
import cpw.mods.fml.relauncher.SideOnly ;
2013-06-13 19:01:54 -04:00
2013-02-17 21:46:16 -05:00
public class EventHookContainer
{
2013-06-13 19:01:54 -04:00
private static DDProperties properties = null ;
public EventHookContainer ( )
{
if ( properties = = null )
properties = DDProperties . instance ( ) ;
}
2013-03-22 00:58:55 -04:00
@SideOnly ( Side . CLIENT )
@ForgeSubscribe
public void onSoundLoad ( SoundLoadEvent event )
{
2013-05-31 02:17:05 -04:00
event . manager . soundPoolSounds . addSound ( " mods/DimDoors/sfx/monk.ogg " , ( mod_pocketDim . class . getResource ( " /mods/DimDoors/sfx/monk.ogg " ) ) ) ;
event . manager . soundPoolSounds . addSound ( " mods/DimDoors/sfx/crack.ogg " , ( mod_pocketDim . class . getResource ( " /mods/DimDoors/sfx/crack.ogg " ) ) ) ;
event . manager . soundPoolSounds . addSound ( " mods/DimDoors/sfx/tearing.ogg " , ( mod_pocketDim . class . getResource ( " /mods/DimDoors/sfx/tearing.ogg " ) ) ) ;
2013-07-15 02:45:25 -04:00
event . manager . soundPoolSounds . addSound ( " mods/DimDoors/sfx/rift.ogg " , ( mod_pocketDim . class . getResource ( " /mods/DimDoors/sfx/rift.ogg " ) ) ) ;
event . manager . soundPoolSounds . addSound ( " mods/DimDoors/sfx/riftStart.ogg " , ( mod_pocketDim . class . getResource ( " /mods/DimDoors/sfx/riftStart.ogg " ) ) ) ;
event . manager . soundPoolSounds . addSound ( " mods/DimDoors/sfx/riftEnd.ogg " , ( mod_pocketDim . class . getResource ( " /mods/DimDoors/sfx/riftEnd.ogg " ) ) ) ;
event . manager . soundPoolSounds . addSound ( " mods/DimDoors/sfx/riftClose.ogg " , ( mod_pocketDim . class . getResource ( " /mods/DimDoors/sfx/riftClose.ogg " ) ) ) ;
event . manager . soundPoolSounds . addSound ( " mods/DimDoors/sfx/riftDoor.ogg " , ( mod_pocketDim . class . getResource ( " /mods/DimDoors/sfx/riftDoor.ogg " ) ) ) ;
2013-03-22 00:58:55 -04:00
}
2013-02-17 21:46:16 -05:00
@ForgeSubscribe
public void onWorldLoad ( WorldEvent . Load event )
{
2013-07-25 00:12:13 -04:00
if ( ! mod_pocketDim . hasInitDims & & event . world . provider . dimensionId = = 0 & & ! event . world . isRemote )
2013-02-17 21:46:16 -05:00
{
2013-03-28 21:34:38 -04:00
System . out . println ( " Registering Pocket Dims " ) ;
2013-07-25 00:12:13 -04:00
mod_pocketDim . hasInitDims = true ;
2013-02-17 21:46:16 -05:00
dimHelper . instance . unregsisterDims ( ) ;
dimHelper . dimList . clear ( ) ;
dimHelper . instance . interDimLinkList . clear ( ) ;
dimHelper . instance . initPockets ( ) ;
}
2013-08-17 20:32:30 -04:00
//TODO: In the future, we should iterate over DimHelper's dimension list. We ignore other dimensions anyway.
for ( int dimensionID : dimHelper . getIDs ( ) )
{
World world = dimHelper . getWorld ( dimensionID ) ;
2013-07-25 00:12:13 -04:00
int linkCount = 0 ;
2013-04-01 03:15:16 -04:00
2013-08-17 20:32:30 -04:00
if ( dimHelper . dimList . containsKey ( dimensionID ) )
2013-04-01 03:15:16 -04:00
{
2013-08-17 20:32:30 -04:00
for ( LinkData link : dimHelper . instance . getDimData ( dimensionID ) . getLinksInDim ( ) )
2013-04-01 03:15:16 -04:00
{
2013-08-17 20:32:30 -04:00
if ( ! mod_pocketDim . blockRift . isBlockImmune ( world , link . locXCoord , link . locYCoord , link . locZCoord ) )
{
world . setBlock ( link . locXCoord , link . locYCoord , link . locZCoord , properties . RiftBlockID ) ;
}
linkCount + + ;
if ( linkCount > = 100 )
{
break ;
}
2013-04-01 03:15:16 -04:00
}
}
2013-07-11 20:42:57 -04:00
}
2013-02-17 21:46:16 -05:00
}
2013-07-11 20:42:57 -04:00
2013-02-17 21:46:16 -05:00
@ForgeSubscribe
public void onPlayerFall ( LivingFallEvent event )
{
2013-07-25 00:12:13 -04:00
event . setCanceled ( event . entity . worldObj . provider . dimensionId = = properties . LimboDimensionID ) ;
2013-02-17 21:46:16 -05:00
}
2013-07-11 20:42:57 -04:00
2013-02-17 21:46:16 -05:00
@ForgeSubscribe
public void onPlayerDrops ( PlayerDropsEvent event )
{
2013-07-25 00:12:13 -04:00
//TODO: I have some doubts. Is this triggered even if you die outside Limbo? And do you still drop items that others could pick up? We don't cancel the event. ~SenseiKiwi
2013-04-07 00:37:13 -04:00
mod_pocketDim . limboSpawnInventory . put ( event . entityPlayer . username , event . drops ) ;
2013-02-17 21:46:16 -05:00
}
@ForgeSubscribe
public void onWorldsave ( WorldEvent . Save event )
{
2013-07-25 00:12:13 -04:00
if ( mod_pocketDim . hasInitDims & & event . world . provider . dimensionId = = 0 )
2013-02-17 21:46:16 -05:00
{
dimHelper . instance . save ( ) ;
}
}
}