From a44181a1928b8cee399e17ff9ac095540cbb9160 Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 11 Sep 2012 18:30:09 -0700 Subject: [PATCH] Move spawn fuzz to WorldProvider/WorldType, useful for VoidWorld types. --- .../minecraft/src/EntityPlayerMP.java.patch | 21 +++++++++++++++++- .../minecraft/src/WorldProvider.java.patch | 19 +++++++++++++++- .../net/minecraft/src/WorldType.java.patch | 22 +++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 patches/common/net/minecraft/src/WorldType.java.patch diff --git a/patches/common/net/minecraft/src/EntityPlayerMP.java.patch b/patches/common/net/minecraft/src/EntityPlayerMP.java.patch index 71bc48123..847069f8a 100644 --- a/patches/common/net/minecraft/src/EntityPlayerMP.java.patch +++ b/patches/common/net/minecraft/src/EntityPlayerMP.java.patch @@ -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) { diff --git a/patches/common/net/minecraft/src/WorldProvider.java.patch b/patches/common/net/minecraft/src/WorldProvider.java.patch index 0a28d6075..db7098228 100644 --- a/patches/common/net/minecraft/src/WorldProvider.java.patch +++ b/patches/common/net/minecraft/src/WorldProvider.java.patch @@ -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; ++ } } diff --git a/patches/common/net/minecraft/src/WorldType.java.patch b/patches/common/net/minecraft/src/WorldType.java.patch new file mode 100644 index 000000000..a0db65847 --- /dev/null +++ b/patches/common/net/minecraft/src/WorldType.java.patch @@ -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; ++ } + }