Move spawn fuzz to WorldProvider/WorldType, useful for VoidWorld types.

This commit is contained in:
LexManos 2012-09-11 18:30:09 -07:00
parent af6b8820d4
commit a44181a192
3 changed files with 60 additions and 2 deletions

View file

@ -10,7 +10,26 @@
public class EntityPlayerMP extends EntityPlayer implements ICrafting
{
@@ -329,8 +332,27 @@
@@ -78,17 +81,10 @@
par4ItemInWorldManager.thisPlayerMP = this;
this.theItemInWorldManager = par4ItemInWorldManager;
this.renderDistance = par1MinecraftServer.getConfigurationManager().getViewDistance();
- ChunkCoordinates var5 = par2World.getSpawnPoint();
+ ChunkCoordinates var5 = par2World.provider.getRandomizedSpawnPoint();
int var6 = var5.posX;
int var7 = var5.posZ;
int var8 = var5.posY;
-
- if (!par2World.provider.hasNoSky && par2World.getWorldInfo().getGameType() != EnumGameType.ADVENTURE)
- {
- var6 += this.rand.nextInt(20) - 10;
- var8 = par2World.getTopSolidOrLiquidBlock(var6, var7);
- var7 += this.rand.nextInt(20) - 10;
- }
this.setLocationAndAngles((double)var6 + 0.5D, (double)var8, (double)var7 + 0.5D, 0.0F, 0.0F);
this.mcServer = par1MinecraftServer;
@@ -329,8 +325,27 @@
*/
public void onDeath(DamageSource par1DamageSource)
{

View file

@ -26,7 +26,7 @@
}
@SideOnly(Side.CLIENT)
@@ -251,4 +255,92 @@
@@ -251,4 +255,109 @@
}
public abstract String func_80007_l();
@ -118,4 +118,21 @@
+ this.skyProvider = skyProvider;
+ }
+
+ public ChunkCoordinates getRandomizedSpawnPoint()
+ {
+ ChunkCoordinates var5 = new ChunkCoordinates(this.worldObj.getSpawnPoint());
+
+ boolean isAdventure = worldObj.getWorldInfo().getGameType() != EnumGameType.ADVENTURE;
+ int spawnFuzz = terrainType.getSpawnFuzz();
+ int spawnFuzzHalf = spawnFuzz / 2;
+
+ if (!this.hasNoSky && !isAdventure)
+ {
+ var5.posX += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf;
+ var5.posZ += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf;
+ var5.posY = this.worldObj.getTopSolidOrLiquidBlock(var5.posX, var5.posZ);
+ }
+
+ return var5;
+ }
}

View file

@ -0,0 +1,22 @@
--- ../src_base/common/net/minecraft/src/WorldType.java
+++ ../src_work/common/net/minecraft/src/WorldType.java
@@ -203,8 +203,19 @@
{
return this == FLAT ? random.nextInt(4) != 1 : false;
}
+
/**
* Called when 'Create New World' button is pressed before starting game
*/
public void onGUICreateWorldPress() { }
+
+ /**
+ * Gets the spawn fuzz for players who join the world.
+ * Useful for void world types.
+ * @return Fuzz for entity initial spawn in blocks.
+ */
+ public int getSpawnFuzz()
+ {
+ return 20;
+ }
}