Added CreateSpawnPosition event Closes #1053

This commit is contained in:
Lex Manos 2014-12-07 01:52:17 -08:00
parent 9cf9d6a8e8
commit 877ba864e7
3 changed files with 44 additions and 14 deletions

View File

@ -179,7 +179,15 @@
protected void func_72963_a(WorldSettings p_72963_1_)
{
if (this.field_73066_T == null)
@@ -726,7 +769,7 @@
@@ -681,6 +724,7 @@
}
else
{
+ if (net.minecraftforge.event.ForgeEventFactory.onCreateWorldSpawn(this, p_73052_1_)) return;
this.field_72987_B = true;
WorldChunkManager worldchunkmanager = this.field_73011_w.field_76578_c;
List list = worldchunkmanager.func_76932_a();
@@ -726,7 +770,7 @@
protected void func_73047_i()
{
@ -188,7 +196,7 @@
for (int i = 0; i < 10; ++i)
{
@@ -763,6 +806,7 @@
@@ -763,6 +807,7 @@
}
this.field_73020_y.func_73151_a(p_73044_1_, p_73044_2_);
@ -196,7 +204,7 @@
ArrayList arraylist = Lists.newArrayList(this.field_73059_b.func_152380_a());
Iterator iterator = arraylist.iterator();
@@ -791,6 +835,7 @@
@@ -791,6 +836,7 @@
this.func_72906_B();
this.field_73019_z.func_75755_a(this.field_72986_A, this.field_73061_a.func_71203_ab().func_72378_q());
this.field_72988_C.func_75744_a();
@ -204,7 +212,7 @@
}
public void func_72923_a(Entity p_72923_1_)
@@ -851,6 +896,7 @@
@@ -851,6 +897,7 @@
Explosion explosion = new Explosion(this, p_72885_1_, p_72885_2_, p_72885_4_, p_72885_6_, p_72885_8_);
explosion.field_77286_a = p_72885_9_;
explosion.field_82755_b = p_72885_10_;
@ -212,7 +220,7 @@
explosion.func_77278_a();
explosion.func_77279_a(false);
@@ -941,19 +987,23 @@
@@ -941,19 +988,23 @@
this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(8, this.field_73017_q), this.field_73011_w.field_76574_g);
}
@ -240,7 +248,7 @@
}
}
@@ -1002,6 +1052,11 @@
@@ -1002,6 +1053,11 @@
}
}

View File

@ -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));
}
}

View File

@ -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;
}
}
}