2013-02-18 03:46:16 +01:00
|
|
|
package StevenDimDoors.mod_pocketDim;
|
2013-06-14 01:01:54 +02:00
|
|
|
|
2013-09-06 21:36:12 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.util.ChunkCoordinates;
|
2013-03-22 05:58:55 +01:00
|
|
|
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
2013-09-06 21:36:12 +02:00
|
|
|
import net.minecraftforge.event.EventPriority;
|
2013-02-18 03:46:16 +01:00
|
|
|
import net.minecraftforge.event.ForgeSubscribe;
|
2013-09-06 21:36:12 +02:00
|
|
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
2013-02-18 03:46:16 +01:00
|
|
|
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
|
|
|
import net.minecraftforge.event.world.WorldEvent;
|
2013-09-06 21:36:12 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
2013-08-29 08:14:24 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
|
|
|
import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator;
|
2013-09-06 21:36:12 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
|
|
|
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
|
|
|
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
2013-07-25 06:12:13 +02:00
|
|
|
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-09-01 15:21:27 +02:00
|
|
|
private final DDProperties properties;
|
2013-06-14 01:01:54 +02:00
|
|
|
|
2013-09-01 15:21:27 +02:00
|
|
|
public EventHookContainer(DDProperties properties)
|
2013-06-14 01:01:54 +02:00
|
|
|
{
|
2013-09-01 15:21:27 +02:00
|
|
|
this.properties = properties;
|
2013-06-14 01:01:54 +02:00
|
|
|
}
|
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-09-04 00:28:42 +02:00
|
|
|
// We need to initialize PocketManager here because onServerAboutToStart fires before we can
|
|
|
|
// use DimensionManager and onServerStarting fires after the game tries to generate terrain.
|
|
|
|
// If a gateway tries to generate before PocketManager has initialized, we get a crash.
|
|
|
|
if (!PocketManager.isLoaded())
|
|
|
|
{
|
|
|
|
PocketManager.load();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PocketManager.isLoaded())
|
|
|
|
{
|
|
|
|
RiftRegenerator.regenerateRiftsInAllWorlds();
|
|
|
|
}
|
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-09-06 21:36:12 +02:00
|
|
|
|
|
|
|
@ForgeSubscribe(priority=EventPriority.HIGHEST)
|
|
|
|
public boolean LivingDeathEvent(LivingDeathEvent event)
|
2013-02-18 03:46:16 +01:00
|
|
|
{
|
2013-09-06 21:36:12 +02:00
|
|
|
Entity entity = event.entity;
|
2013-09-07 04:14:27 +02:00
|
|
|
if (entity instanceof EntityPlayer && entity.worldObj.provider instanceof PocketProvider
|
|
|
|
&& properties.LimboEnabled)
|
2013-09-06 21:36:12 +02:00
|
|
|
{
|
2013-09-07 04:14:27 +02:00
|
|
|
EntityPlayer player = (EntityPlayer) entity;
|
|
|
|
if (!properties.LimboReturnsInventoryEnabled)
|
2013-09-06 21:43:22 +02:00
|
|
|
{
|
2013-09-07 04:14:27 +02:00
|
|
|
player.inventory.clearInventory(-1, -1);
|
2013-09-06 21:43:22 +02:00
|
|
|
}
|
2013-09-07 04:14:27 +02:00
|
|
|
ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(player.worldObj.rand);
|
|
|
|
DDTeleporter.teleportEntity(player, new Point4D(coords.posX, coords.posY, coords.posZ, mod_pocketDim.properties.LimboDimensionID));
|
|
|
|
player.setEntityHealth(player.getMaxHealth());
|
2013-09-06 21:36:12 +02:00
|
|
|
event.setCanceled(true);
|
2013-09-06 21:43:22 +02:00
|
|
|
return false;
|
2013-09-06 21:36:12 +02:00
|
|
|
}
|
|
|
|
return true;
|
2013-02-18 03:46:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@ForgeSubscribe
|
|
|
|
public void onWorldsave(WorldEvent.Save event)
|
|
|
|
{
|
2013-09-01 15:21:27 +02:00
|
|
|
if (event.world.provider.dimensionId == 0)
|
2013-02-18 03:46:16 +01:00
|
|
|
{
|
2013-08-29 08:14:24 +02:00
|
|
|
PocketManager.save();
|
2013-02-18 03:46:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|