2013-02-18 03:46:16 +01:00
package StevenDimDoors.mod_pocketDim ;
2013-06-14 01:01:54 +02:00
2013-02-18 03:46:16 +01:00
import net.minecraft.world.World ;
2013-03-22 05:58:55 +01:00
import net.minecraftforge.client.event.sound.SoundLoadEvent ;
2013-02-18 03:46:16 +01: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 06:12:13 +02:00
import StevenDimDoors.mod_pocketDim.helpers.dimHelper ;
import cpw.mods.fml.relauncher.Side ;
import cpw.mods.fml.relauncher.SideOnly ;
2013-06-14 01:01:54 +02:00
2013-02-18 03:46:16 +01:00
public class EventHookContainer
{
2013-06-14 01:01:54 +02:00
private static DDProperties properties = null ;
public EventHookContainer ( )
{
if ( properties = = null )
properties = DDProperties . instance ( ) ;
}
2013-03-22 05:58:55 +01:00
@SideOnly ( Side . CLIENT )
@ForgeSubscribe
public void onSoundLoad ( SoundLoadEvent event )
{
2013-05-31 08:17:05 +02: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 08:45:25 +02: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 05:58:55 +01:00
}
2013-02-18 03:46:16 +01:00
@ForgeSubscribe
public void onWorldLoad ( WorldEvent . Load event )
{
2013-07-25 06:12:13 +02:00
if ( ! mod_pocketDim . hasInitDims & & event . world . provider . dimensionId = = 0 & & ! event . world . isRemote )
2013-02-18 03:46:16 +01:00
{
2013-03-29 02:34:38 +01:00
System . out . println ( " Registering Pocket Dims " ) ;
2013-07-25 06:12:13 +02:00
mod_pocketDim . hasInitDims = true ;
2013-02-18 03:46:16 +01:00
dimHelper . instance . unregsisterDims ( ) ;
dimHelper . dimList . clear ( ) ;
dimHelper . instance . interDimLinkList . clear ( ) ;
dimHelper . instance . initPockets ( ) ;
}
2013-07-25 06:12:13 +02:00
for ( Integer ids : dimHelper . getIDs ( ) )
2013-04-01 09:15:16 +02:00
{
2013-04-07 06:37:13 +02:00
World world = dimHelper . getWorld ( ids ) ;
2013-07-25 06:12:13 +02:00
int linkCount = 0 ;
2013-04-01 09:15:16 +02:00
2013-07-25 06:12:13 +02:00
if ( dimHelper . dimList . containsKey ( world . provider . dimensionId ) )
2013-04-01 09:15:16 +02:00
{
2013-07-12 02:42:57 +02:00
//TODO added temporary Try/catch block to prevent a crash here, getLinksInDim needs to be looked at
try
{
2013-08-01 01:34:08 +02:00
for ( LinkData link : dimHelper . instance . getDimData ( world . provider . dimensionId ) . getLinksInDim ( ) )
2013-07-12 02:42:57 +02:00
{
2013-08-03 12:12:56 +02:00
if ( ! mod_pocketDim . blockRift . isBlockImmune ( world , link . locXCoord , link . locYCoord , link . locZCoord ) )
2013-07-12 02:42:57 +02:00
{
2013-08-03 12:12:56 +02:00
dimHelper . getWorld ( link . locDimID ) . setBlock ( link . locXCoord , link . locYCoord , link . locZCoord , properties . RiftBlockID ) ;
2013-07-12 02:42:57 +02:00
}
linkCount + + ;
2013-08-03 12:12:56 +02:00
if ( linkCount > = 100 )
2013-07-12 02:42:57 +02:00
{
2013-08-03 12:12:56 +02:00
break ;
2013-07-12 02:42:57 +02:00
}
}
}
catch ( Exception e )
2013-04-01 09:15:16 +02:00
{
2013-07-12 02:42:57 +02:00
e . printStackTrace ( ) ;
2013-04-01 09:15:16 +02:00
}
}
2013-07-12 02:42:57 +02:00
}
2013-02-18 03:46:16 +01:00
}
2013-07-12 02:42:57 +02:00
2013-02-18 03:46:16 +01:00
@ForgeSubscribe
public void onPlayerFall ( LivingFallEvent event )
{
2013-07-25 06:12:13 +02:00
event . setCanceled ( event . entity . worldObj . provider . dimensionId = = properties . LimboDimensionID ) ;
2013-02-18 03:46:16 +01:00
}
2013-07-12 02:42:57 +02:00
2013-02-18 03:46:16 +01:00
@ForgeSubscribe
public void onPlayerDrops ( PlayerDropsEvent event )
{
2013-07-25 06:12:13 +02: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 06:37:13 +02:00
mod_pocketDim . limboSpawnInventory . put ( event . entityPlayer . username , event . drops ) ;
2013-02-18 03:46:16 +01:00
}
@ForgeSubscribe
public void onWorldsave ( WorldEvent . Save event )
{
2013-07-25 06:12:13 +02:00
if ( mod_pocketDim . hasInitDims & & event . world . provider . dimensionId = = 0 )
2013-02-18 03:46:16 +01:00
{
dimHelper . instance . save ( ) ;
}
}
}