Added CreateSpawnPosition event.

This commit is contained in:
Lex Manos 2014-12-07 01:52:29 -08:00
parent 0c11a1544f
commit f2b1622355
3 changed files with 37 additions and 6 deletions

View file

@ -174,7 +174,15 @@
return !this.field_73061_a.func_175579_a(this, p_175660_2_, p_175660_1_) && this.func_175723_af().func_177746_a(p_175660_2_);
}
@@ -855,7 +898,7 @@
@@ -810,6 +853,7 @@
}
else
{
+ if (net.minecraftforge.event.ForgeEventFactory.onCreateWorldSpawn(this, p_73052_1_)) return;
this.field_72987_B = true;
WorldChunkManager worldchunkmanager = this.field_73011_w.func_177499_m();
List list = worldchunkmanager.func_76932_a();
@@ -855,7 +899,7 @@
protected void func_73047_i()
{
@ -183,7 +191,7 @@
for (int i = 0; i < 10; ++i)
{
@@ -892,6 +935,7 @@
@@ -892,6 +936,7 @@
}
this.field_73020_y.func_73151_a(p_73044_1_, p_73044_2_);
@ -191,7 +199,7 @@
List list = this.field_73059_b.func_152380_a();
Iterator iterator = list.iterator();
@@ -929,6 +973,7 @@
@@ -929,6 +974,7 @@
this.field_72986_A.func_176135_e(this.func_175723_af().func_177732_i());
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();
@ -199,7 +207,7 @@
}
public void func_72923_a(Entity p_72923_1_)
@@ -984,6 +1029,7 @@
@@ -984,6 +1030,7 @@
public Explosion func_72885_a(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_)
{
Explosion explosion = new Explosion(this, p_72885_1_, p_72885_2_, p_72885_4_, p_72885_6_, p_72885_8_, p_72885_9_, p_72885_10_);
@ -207,7 +215,7 @@
explosion.func_77278_a();
explosion.func_77279_a(false);
@@ -1074,19 +1120,23 @@
@@ -1074,19 +1121,23 @@
this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(8, this.field_73017_q), this.field_73011_w.func_177502_q());
}
@ -235,7 +243,7 @@
}
}
@@ -1152,6 +1202,11 @@
@@ -1152,6 +1203,11 @@
return this.field_73061_a.func_152345_ab();
}

View file

@ -27,6 +27,7 @@ import net.minecraft.util.Vec3;
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;
@ -372,4 +373,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

@ -2,9 +2,11 @@ package net.minecraftforge.event.world;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
@ -109,4 +111,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 settings)
{
super(world);
this.settings = settings;
}
}
}