mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Added CreateSpawnPosition event Closes #1053
This commit is contained in:
1 parent
9cf9d6a8e8
commit
877ba864e7
3 files changed
+44
-14
No files matched your search
@@ -21,6 +21,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.storage.IPlayerFileData;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
@@ -240,4 +241,9 @@ public class ForgeEventFactory
|
||||
*/
|
||||
MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Detonate(world, explosion, list));
|
||||
}
|
||||
|
||||
public static boolean onCreateWorldSpawn(World world, WorldSettings settings)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new WorldEvent.CreateSpawnPosition(world, settings));
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,14 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
* WorldEvent is fired when an event involving the world occurs.<br>
|
||||
* If a method utilizes this {@link Event} as its parameter, the method will
|
||||
* If a method utilizes this {@link Event} as its parameter, the method will
|
||||
* receive every child event of this class.<br>
|
||||
* <br>
|
||||
* {@link #world} contains the World this event is occuring in.<br>
|
||||
@@ -31,8 +32,8 @@ public class WorldEvent extends Event
|
||||
* WorldEvent.Load is fired when Minecraft loads a world.<br>
|
||||
* This event is fired when a world is loaded in
|
||||
* WorldClient#WorldClient(NetHandlerPlayClient, WorldSettings, int, EnumDifficulty, Profiler),
|
||||
* MinecraftServer#loadAllWorlds(String, String, long, WorldType, String),
|
||||
* DimensionManager#initDimension(int),
|
||||
* MinecraftServer#loadAllWorlds(String, String, long, WorldType, String),
|
||||
* DimensionManager#initDimension(int),
|
||||
* and ForgeInternalHandler#onDimensionLoad(Load). <br>
|
||||
* <br>
|
||||
* This event is not {@link Cancelable}.<br>
|
||||
@@ -49,10 +50,10 @@ public class WorldEvent extends Event
|
||||
/**
|
||||
* WorldEvent.Unload is fired when Minecraft unloads a world.<br>
|
||||
* This event is fired when a world is unloaded in
|
||||
* Minecraft#loadWorld(WorldClient, String),
|
||||
* MinecraftServer#deleteWorldAndStopServer(),
|
||||
* MinecraftServer#stopServer(),
|
||||
* DimensionManager#unloadWorlds(Hashtable<Integer, long[]>),
|
||||
* Minecraft#loadWorld(WorldClient, String),
|
||||
* MinecraftServer#deleteWorldAndStopServer(),
|
||||
* MinecraftServer#stopServer(),
|
||||
* DimensionManager#unloadWorlds(Hashtable<Integer, long[]>),
|
||||
* ForgeInternalHandler#onDimensionUnload(Unload). <br>
|
||||
* <br>
|
||||
* This event is not {@link Cancelable}.<br>
|
||||
@@ -69,7 +70,7 @@ public class WorldEvent extends Event
|
||||
/**
|
||||
* WorldEvent.Save is fired when Minecraft saves a world.<br>
|
||||
* This event is fired when a world is saved in
|
||||
* WorldServer#saveAllChunks(boolean, IProgressUpdate),
|
||||
* WorldServer#saveAllChunks(boolean, IProgressUpdate),
|
||||
* ForgeInternalHandler#onDimensionSave(Save). <br>
|
||||
* <br>
|
||||
* This event is not {@link Cancelable}.<br>
|
||||
@@ -113,4 +114,19 @@ public class WorldEvent extends Event
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by WorldServer when it attempts to create a spawnpoint for a dimension.
|
||||
* Canceling the event will prevent the vanilla code from running.
|
||||
*/
|
||||
@Cancelable
|
||||
public static class CreateSpawnPosition extends WorldEvent
|
||||
{
|
||||
public final WorldSettings settings;
|
||||
public CreateSpawnPosition(World world, WorldSettings ws)
|
||||
{
|
||||
super(world);
|
||||
this.settings = ws;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user