Fix cast issue when mods attempt to make fake worlds.

This commit is contained in:
LexManos 2012-10-28 23:41:43 -07:00
parent 6c803ea1de
commit f9ea207cdc

View file

@ -76,12 +76,19 @@
this.worldInfo = par1ISaveHandler.loadWorldInfo(); this.worldInfo = par1ISaveHandler.loadWorldInfo();
if (par4WorldProvider != null) if (par4WorldProvider != null)
@@ -227,12 +260,13 @@ @@ -227,12 +260,20 @@
this.worldInfo.setServerInitialized(true); this.worldInfo.setServerInitialized(true);
} }
- VillageCollection var6 = (VillageCollection)this.mapStorage.loadData(VillageCollection.class, "villages"); - VillageCollection var6 = (VillageCollection)this.mapStorage.loadData(VillageCollection.class, "villages");
+ if (this instanceof WorldServer)
+ {
+ this.perWorldStorage = new MapStorage(new WorldSpecificSaveHandler((WorldServer)this, par1ISaveHandler)); + this.perWorldStorage = new MapStorage(new WorldSpecificSaveHandler((WorldServer)this, par1ISaveHandler));
+ }
+ else
+ {
+ this.perWorldStorage = new MapStorage((ISaveHandler)null);
+ }
+ VillageCollection var6 = (VillageCollection)perWorldStorage.loadData(VillageCollection.class, "villages"); + VillageCollection var6 = (VillageCollection)perWorldStorage.loadData(VillageCollection.class, "villages");
if (var6 == null) if (var6 == null)
@ -92,7 +99,7 @@
} }
else else
{ {
@@ -244,6 +278,19 @@ @@ -244,6 +285,19 @@
this.calculateInitialWeather(); this.calculateInitialWeather();
} }
@ -112,7 +119,7 @@
/** /**
* Creates the chunk provider for this world. Called in the constructor. Retrieves provider from worldProvider? * Creates the chunk provider for this world. Called in the constructor. Retrieves provider from worldProvider?
*/ */
@@ -298,7 +345,8 @@ @@ -298,7 +352,8 @@
*/ */
public boolean isAirBlock(int par1, int par2, int par3) public boolean isAirBlock(int par1, int par2, int par3)
{ {
@ -122,7 +129,7 @@
} }
/** /**
@@ -307,7 +355,8 @@ @@ -307,7 +362,8 @@
public boolean blockHasTileEntity(int par1, int par2, int par3) public boolean blockHasTileEntity(int par1, int par2, int par3)
{ {
int var4 = this.getBlockId(par1, par2, par3); int var4 = this.getBlockId(par1, par2, par3);
@ -132,7 +139,7 @@
} }
/** /**
@@ -1029,7 +1078,7 @@ @@ -1029,7 +1085,7 @@
*/ */
public boolean isDaytime() public boolean isDaytime()
{ {
@ -141,7 +148,7 @@
} }
/** /**
@@ -1061,7 +1110,7 @@ @@ -1061,7 +1117,7 @@
int var12 = this.getBlockMetadata(var8, var9, var10); int var12 = this.getBlockMetadata(var8, var9, var10);
Block var13 = Block.blocksList[var11]; Block var13 = Block.blocksList[var11];
@ -150,7 +157,7 @@
{ {
MovingObjectPosition var14 = var13.collisionRayTrace(this, var8, var9, var10, par1Vec3, par2Vec3); MovingObjectPosition var14 = var13.collisionRayTrace(this, var8, var9, var10, par1Vec3, par2Vec3);
@@ -1261,6 +1310,12 @@ @@ -1261,6 +1317,12 @@
*/ */
public void playSoundAtEntity(Entity par1Entity, String par2Str, float par3, float par4) public void playSoundAtEntity(Entity par1Entity, String par2Str, float par3, float par4)
{ {
@ -163,7 +170,7 @@
if (par1Entity != null && par2Str != null) if (par1Entity != null && par2Str != null)
{ {
Iterator var5 = this.worldAccesses.iterator(); Iterator var5 = this.worldAccesses.iterator();
@@ -1359,6 +1414,11 @@ @@ -1359,6 +1421,11 @@
EntityPlayer var5 = (EntityPlayer)par1Entity; EntityPlayer var5 = (EntityPlayer)par1Entity;
this.playerEntities.add(var5); this.playerEntities.add(var5);
this.updateAllPlayersSleepingFlag(); this.updateAllPlayersSleepingFlag();
@ -175,7 +182,7 @@
} }
this.getChunkFromChunkCoords(var2, var3).addEntity(par1Entity); this.getChunkFromChunkCoords(var2, var3).addEntity(par1Entity);
@@ -1610,6 +1670,12 @@ @@ -1610,6 +1677,12 @@
* Calculates the color for the skybox * Calculates the color for the skybox
*/ */
public Vec3 getSkyColor(Entity par1Entity, float par2) public Vec3 getSkyColor(Entity par1Entity, float par2)
@ -188,7 +195,7 @@
{ {
float var3 = this.getCelestialAngle(par2); float var3 = this.getCelestialAngle(par2);
float var4 = MathHelper.cos(var3 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; float var4 = MathHelper.cos(var3 * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
@@ -1705,6 +1771,12 @@ @@ -1705,6 +1778,12 @@
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public Vec3 drawClouds(float par1) public Vec3 drawClouds(float par1)
{ {
@ -201,7 +208,7 @@
float var2 = this.getCelestialAngle(par1); float var2 = this.getCelestialAngle(par1);
float var3 = MathHelper.cos(var2 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; float var3 = MathHelper.cos(var2 * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
@@ -1783,7 +1855,7 @@ @@ -1783,7 +1862,7 @@
{ {
int var5 = var3.getBlockID(par1, var4, par2); int var5 = var3.getBlockID(par1, var4, par2);
@ -210,7 +217,7 @@
{ {
return var4 + 1; return var4 + 1;
} }
@@ -1798,6 +1870,12 @@ @@ -1798,6 +1877,12 @@
* How bright are stars in the sky * How bright are stars in the sky
*/ */
public float getStarBrightness(float par1) public float getStarBrightness(float par1)
@ -223,7 +230,7 @@
{ {
float var2 = this.getCelestialAngle(par1); float var2 = this.getCelestialAngle(par1);
float var3 = 1.0F - (MathHelper.cos(var2 * (float)Math.PI * 2.0F) * 2.0F + 0.25F); float var3 = 1.0F - (MathHelper.cos(var2 * (float)Math.PI * 2.0F) * 2.0F + 0.25F);
@@ -1942,7 +2020,7 @@ @@ -1942,7 +2027,7 @@
if (var8 != null) if (var8 != null)
{ {
@ -232,7 +239,7 @@
} }
} }
} }
@@ -1952,6 +2030,10 @@ @@ -1952,6 +2037,10 @@
if (!this.entityRemoval.isEmpty()) if (!this.entityRemoval.isEmpty())
{ {
@ -243,7 +250,7 @@
this.loadedTileEntityList.removeAll(this.entityRemoval); this.loadedTileEntityList.removeAll(this.entityRemoval);
this.entityRemoval.clear(); this.entityRemoval.clear();
} }
@@ -1972,7 +2054,9 @@ @@ -1972,7 +2061,9 @@
{ {
this.loadedTileEntityList.add(var9); this.loadedTileEntityList.add(var9);
} }
@ -254,7 +261,7 @@
if (this.chunkExists(var9.xCoord >> 4, var9.zCoord >> 4)) if (this.chunkExists(var9.xCoord >> 4, var9.zCoord >> 4))
{ {
Chunk var10 = this.getChunkFromChunkCoords(var9.xCoord >> 4, var9.zCoord >> 4); Chunk var10 = this.getChunkFromChunkCoords(var9.xCoord >> 4, var9.zCoord >> 4);
@@ -1982,8 +2066,6 @@ @@ -1982,8 +2073,6 @@
var10.setChunkBlockTileEntity(var9.xCoord & 15, var9.yCoord, var9.zCoord & 15, var9); var10.setChunkBlockTileEntity(var9.xCoord & 15, var9.yCoord, var9.zCoord & 15, var9);
} }
} }
@ -263,7 +270,7 @@
} }
} }
@@ -1996,13 +2078,13 @@ @@ -1996,13 +2085,13 @@
public void addTileEntity(Collection par1Collection) public void addTileEntity(Collection par1Collection)
{ {
@ -284,7 +291,7 @@
} }
} }
@@ -2022,9 +2104,17 @@ @@ -2022,9 +2111,17 @@
{ {
int var3 = MathHelper.floor_double(par1Entity.posX); int var3 = MathHelper.floor_double(par1Entity.posX);
int var4 = MathHelper.floor_double(par1Entity.posZ); int var4 = MathHelper.floor_double(par1Entity.posZ);
@ -305,7 +312,7 @@
{ {
par1Entity.lastTickPosX = par1Entity.posX; par1Entity.lastTickPosX = par1Entity.posX;
par1Entity.lastTickPosY = par1Entity.posY; par1Entity.lastTickPosY = par1Entity.posY;
@@ -2259,6 +2349,14 @@ @@ -2259,6 +2356,14 @@
{ {
return true; return true;
} }
@ -320,7 +327,7 @@
} }
} }
} }
@@ -2566,25 +2664,21 @@ @@ -2566,25 +2671,21 @@
*/ */
public void setBlockTileEntity(int par1, int par2, int par3, TileEntity par4TileEntity) public void setBlockTileEntity(int par1, int par2, int par3, TileEntity par4TileEntity)
{ {
@ -361,7 +368,7 @@
} }
} }
@@ -2593,27 +2687,10 @@ @@ -2593,27 +2694,10 @@
*/ */
public void removeBlockTileEntity(int par1, int par2, int par3) public void removeBlockTileEntity(int par1, int par2, int par3)
{ {
@ -393,7 +400,7 @@
} }
} }
@@ -2639,7 +2716,8 @@ @@ -2639,7 +2723,8 @@
*/ */
public boolean isBlockNormalCube(int par1, int par2, int par3) public boolean isBlockNormalCube(int par1, int par2, int par3)
{ {
@ -403,7 +410,7 @@
} }
/** /**
@@ -2647,8 +2725,7 @@ @@ -2647,8 +2732,7 @@
*/ */
public boolean doesBlockHaveSolidTopSurface(int par1, int par2, int par3) public boolean doesBlockHaveSolidTopSurface(int par1, int par2, int par3)
{ {
@ -413,7 +420,7 @@
} }
/** /**
@@ -2664,7 +2741,7 @@ @@ -2664,7 +2748,7 @@
if (var5 != null && !var5.isEmpty()) if (var5 != null && !var5.isEmpty())
{ {
Block var6 = Block.blocksList[this.getBlockId(par1, par2, par3)]; Block var6 = Block.blocksList[this.getBlockId(par1, par2, par3)];
@ -422,7 +429,7 @@
} }
else else
{ {
@@ -2695,8 +2772,7 @@ @@ -2695,8 +2779,7 @@
*/ */
public void setAllowedSpawnTypes(boolean par1, boolean par2) public void setAllowedSpawnTypes(boolean par1, boolean par2)
{ {
@ -432,7 +439,7 @@
} }
/** /**
@@ -2712,6 +2788,11 @@ @@ -2712,6 +2795,11 @@
*/ */
private void calculateInitialWeather() private void calculateInitialWeather()
{ {
@ -444,7 +451,7 @@
if (this.worldInfo.isRaining()) if (this.worldInfo.isRaining())
{ {
this.rainingStrength = 1.0F; this.rainingStrength = 1.0F;
@@ -2727,6 +2808,11 @@ @@ -2727,6 +2815,11 @@
* Updates all weather states. * Updates all weather states.
*/ */
protected void updateWeather() protected void updateWeather()
@ -456,7 +463,7 @@
{ {
if (!this.provider.hasNoSky) if (!this.provider.hasNoSky)
{ {
@@ -2829,12 +2915,14 @@ @@ -2829,12 +2922,14 @@
public void toggleRain() public void toggleRain()
{ {
@ -472,7 +479,7 @@
this.theProfiler.startSection("buildList"); this.theProfiler.startSection("buildList");
int var1; int var1;
EntityPlayer var2; EntityPlayer var2;
@@ -2941,6 +3029,11 @@ @@ -2941,6 +3036,11 @@
*/ */
public boolean canBlockFreeze(int par1, int par2, int par3, boolean par4) public boolean canBlockFreeze(int par1, int par2, int par3, boolean par4)
{ {
@ -484,7 +491,7 @@
BiomeGenBase var5 = this.getBiomeGenForCoords(par1, par3); BiomeGenBase var5 = this.getBiomeGenForCoords(par1, par3);
float var6 = var5.getFloatTemperature(); float var6 = var5.getFloatTemperature();
@@ -2998,6 +3091,11 @@ @@ -2998,6 +3098,11 @@
* Tests whether or not snow can be placed at a given location * Tests whether or not snow can be placed at a given location
*/ */
public boolean canSnowAt(int par1, int par2, int par3) public boolean canSnowAt(int par1, int par2, int par3)
@ -496,7 +503,7 @@
{ {
BiomeGenBase var4 = this.getBiomeGenForCoords(par1, par3); BiomeGenBase var4 = this.getBiomeGenForCoords(par1, par3);
float var5 = var4.getFloatTemperature(); float var5 = var4.getFloatTemperature();
@@ -3091,7 +3189,7 @@ @@ -3091,7 +3196,7 @@
private int computeBlockLightValue(int par1, int par2, int par3, int par4, int par5, int par6) private int computeBlockLightValue(int par1, int par2, int par3, int par4, int par5, int par6)
{ {
@ -505,7 +512,7 @@
int var8 = this.getSavedLightValue(EnumSkyBlock.Block, par2 - 1, par3, par4) - par6; int var8 = this.getSavedLightValue(EnumSkyBlock.Block, par2 - 1, par3, par4) - par6;
int var9 = this.getSavedLightValue(EnumSkyBlock.Block, par2 + 1, par3, par4) - par6; int var9 = this.getSavedLightValue(EnumSkyBlock.Block, par2 + 1, par3, par4) - par6;
int var10 = this.getSavedLightValue(EnumSkyBlock.Block, par2, par3 - 1, par4) - par6; int var10 = this.getSavedLightValue(EnumSkyBlock.Block, par2, par3 - 1, par4) - par6;
@@ -3226,7 +3324,7 @@ @@ -3226,7 +3331,7 @@
int var21 = var24 + (var18 / 2 + 1) % 3 / 2 * var19; int var21 = var24 + (var18 / 2 + 1) % 3 / 2 * var19;
int var22 = var12 + (var18 / 2 + 2) % 3 / 2 * var19; int var22 = var12 + (var18 / 2 + 2) % 3 / 2 * var19;
var14 = this.getSavedLightValue(par1EnumSkyBlock, var20, var21, var22); var14 = this.getSavedLightValue(par1EnumSkyBlock, var20, var21, var22);
@ -514,7 +521,7 @@
if (var23 == 0) if (var23 == 0)
{ {
@@ -3257,7 +3355,7 @@ @@ -3257,7 +3362,7 @@
var12 = (var9 >> 12 & 63) - 32 + par4; var12 = (var9 >> 12 & 63) - 32 + par4;
var13 = this.getSavedLightValue(par1EnumSkyBlock, var10, var24, var12); var13 = this.getSavedLightValue(par1EnumSkyBlock, var10, var24, var12);
var14 = this.getBlockId(var10, var24, var12); var14 = this.getBlockId(var10, var24, var12);
@ -523,7 +530,7 @@
if (var15 == 0) if (var15 == 0)
{ {
@@ -3359,10 +3457,10 @@ @@ -3359,10 +3464,10 @@
public List getEntitiesWithinAABBExcludingEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB) public List getEntitiesWithinAABBExcludingEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB)
{ {
this.entitiesWithinAABBExcludingEntity.clear(); this.entitiesWithinAABBExcludingEntity.clear();
@ -538,7 +545,7 @@
for (int var7 = var3; var7 <= var4; ++var7) for (int var7 = var3; var7 <= var4; ++var7)
{ {
@@ -3388,10 +3486,10 @@ @@ -3388,10 +3493,10 @@
public List func_82733_a(Class par1Class, AxisAlignedBB par2AxisAlignedBB, IEntitySelector par3IEntitySelector) public List func_82733_a(Class par1Class, AxisAlignedBB par2AxisAlignedBB, IEntitySelector par3IEntitySelector)
{ {
@ -553,7 +560,7 @@
ArrayList var8 = new ArrayList(); ArrayList var8 = new ArrayList();
for (int var9 = var4; var9 <= var5; ++var9) for (int var9 = var4; var9 <= var5; ++var9)
@@ -3485,11 +3583,14 @@ @@ -3485,11 +3590,14 @@
*/ */
public void addLoadedEntities(List par1List) public void addLoadedEntities(List par1List)
{ {
@ -571,7 +578,7 @@
} }
} }
@@ -3523,6 +3624,11 @@ @@ -3523,6 +3631,11 @@
else else
{ {
if (var9 != null && (var9 == Block.waterMoving || var9 == Block.waterStill || var9 == Block.lavaMoving || var9 == Block.lavaStill || var9 == Block.fire || var9.blockMaterial.isGroundCover())) if (var9 != null && (var9 == Block.waterMoving || var9 == Block.waterStill || var9 == Block.lavaMoving || var9 == Block.lavaStill || var9 == Block.fire || var9.blockMaterial.isGroundCover()))
@ -583,7 +590,7 @@
{ {
var9 = null; var9 = null;
} }
@@ -3740,7 +3846,7 @@ @@ -3740,7 +3853,7 @@
*/ */
public long getSeed() public long getSeed()
{ {
@ -592,7 +599,7 @@
} }
public long func_82737_E() public long func_82737_E()
@@ -3750,7 +3856,7 @@ @@ -3750,7 +3863,7 @@
public long getWorldTime() public long getWorldTime()
{ {
@ -601,7 +608,7 @@
} }
/** /**
@@ -3758,7 +3864,7 @@ @@ -3758,7 +3871,7 @@
*/ */
public void setWorldTime(long par1) public void setWorldTime(long par1)
{ {
@ -610,7 +617,7 @@
} }
/** /**
@@ -3766,13 +3872,13 @@ @@ -3766,13 +3879,13 @@
*/ */
public ChunkCoordinates getSpawnPoint() public ChunkCoordinates getSpawnPoint()
{ {
@ -626,7 +633,7 @@
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@@ -3796,7 +3902,10 @@ @@ -3796,7 +3909,10 @@
if (!this.loadedEntityList.contains(par1Entity)) if (!this.loadedEntityList.contains(par1Entity))
{ {
@ -638,7 +645,7 @@
} }
} }
@@ -3804,6 +3913,11 @@ @@ -3804,6 +3920,11 @@
* Called when checking if a certain block can be mined or not. The 'spawn safe zone' check is located here. * Called when checking if a certain block can be mined or not. The 'spawn safe zone' check is located here.
*/ */
public boolean canMineBlock(EntityPlayer par1EntityPlayer, int par2, int par3, int par4) public boolean canMineBlock(EntityPlayer par1EntityPlayer, int par2, int par3, int par4)
@ -650,7 +657,7 @@
{ {
return true; return true;
} }
@@ -3921,8 +4035,7 @@ @@ -3921,8 +4042,7 @@
*/ */
public boolean isBlockHighHumidity(int par1, int par2, int par3) public boolean isBlockHighHumidity(int par1, int par2, int par3)
{ {
@ -660,7 +667,7 @@
} }
/** /**
@@ -3984,7 +4097,7 @@ @@ -3984,7 +4104,7 @@
*/ */
public int getHeight() public int getHeight()
{ {
@ -669,7 +676,7 @@
} }
/** /**
@@ -3992,7 +4105,7 @@ @@ -3992,7 +4112,7 @@
*/ */
public int getActualHeight() public int getActualHeight()
{ {
@ -678,7 +685,7 @@
} }
public IUpdatePlayerListBox func_82735_a(EntityMinecart par1EntityMinecart) public IUpdatePlayerListBox func_82735_a(EntityMinecart par1EntityMinecart)
@@ -4035,7 +4148,7 @@ @@ -4035,7 +4155,7 @@
*/ */
public double getHorizon() public double getHorizon()
{ {
@ -687,7 +694,7 @@
} }
/** /**
@@ -4074,4 +4187,75 @@ @@ -4074,4 +4194,75 @@
this.field_83016_L.setTimeInMillis(System.currentTimeMillis()); this.field_83016_L.setTimeInMillis(System.currentTimeMillis());
return this.field_83016_L; return this.field_83016_L;
} }