Redirect a lot of functions through WorldProvider for Mystcraft, allowing them to be overriden by the provider.

This commit is contained in:
LexManos 2012-09-18 21:31:17 -07:00
parent 6b78512a48
commit cf3bc6a9d9
4 changed files with 435 additions and 31 deletions

View File

@ -23,7 +23,19 @@
/**
* boolean; if true updates scheduled by scheduleBlockUpdate happen immediately
*/
@@ -167,6 +181,7 @@
@@ -132,6 +146,11 @@
* Gets the biome for a given set of x/z coordinates
*/
public BiomeGenBase getBiomeGenForCoords(int par1, int par2)
+ {
+ return provider.getBiomeGenForCoords(par1, par2);
+ }
+
+ public BiomeGenBase getBiomeGenForCoordsBody(int par1, int par2)
{
if (this.blockExists(par1, 0, par2))
{
@@ -167,6 +186,7 @@
this.chunkProvider = this.createChunkProvider();
this.calculateInitialSkylight();
this.calculateInitialWeather();
@ -31,7 +43,7 @@
}
public World(ISaveHandler par1ISaveHandler, String par2Str, WorldSettings par3WorldSettings, WorldProvider par4WorldProvider, Profiler par5Profiler)
@@ -213,6 +228,7 @@
@@ -213,6 +233,7 @@
this.calculateInitialSkylight();
this.calculateInitialWeather();
@ -39,7 +51,7 @@
}
/**
@@ -269,7 +285,8 @@
@@ -269,7 +290,8 @@
*/
public boolean isAirBlock(int par1, int par2, int par3)
{
@ -49,7 +61,7 @@
}
/**
@@ -278,7 +295,8 @@
@@ -278,7 +300,8 @@
public boolean blockHasTileEntity(int par1, int par2, int par3)
{
int var4 = this.getBlockId(par1, par2, par3);
@ -59,7 +71,16 @@
}
/**
@@ -1012,7 +1030,7 @@
@@ -980,7 +1003,7 @@
*/
public boolean isDaytime()
{
- return this.skylightSubtracted < 4;
+ return provider.isDaytime();
}
/**
@@ -1012,7 +1035,7 @@
int var12 = this.getBlockMetadata(var8, var9, var10);
Block var13 = Block.blocksList[var11];
@ -68,7 +89,7 @@
{
MovingObjectPosition var14 = var13.collisionRayTrace(this, var8, var9, var10, par1Vec3, par2Vec3);
@@ -1212,6 +1230,12 @@
@@ -1212,6 +1235,12 @@
*/
public void playSoundAtEntity(Entity par1Entity, String par2Str, float par3, float par4)
{
@ -81,7 +102,7 @@
if (par1Entity != null && par2Str != null)
{
Iterator var5 = this.worldAccesses.iterator();
@@ -1312,6 +1336,11 @@
@@ -1312,6 +1341,11 @@
EntityPlayer var5 = (EntityPlayer)par1Entity;
this.playerEntities.add(var5);
this.updateAllPlayersSleepingFlag();
@ -93,7 +114,33 @@
}
this.getChunkFromChunkCoords(var2, var3).addEntity(par1Entity);
@@ -1736,7 +1765,7 @@
@@ -1563,6 +1597,12 @@
* Calculates the color for the skybox
*/
public Vec3 getSkyColor(Entity par1Entity, float par2)
+ {
+ return provider.getSkyColor(par1Entity, par2);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public Vec3 getSkyColorBody(Entity par1Entity, float par2)
{
float var3 = this.getCelestialAngle(par2);
float var4 = MathHelper.cos(var3 * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
@@ -1658,6 +1698,12 @@
@SideOnly(Side.CLIENT)
public Vec3 drawClouds(float par1)
{
+ return provider.drawClouds(par1);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public Vec3 drawCloudsBody(float par1)
+ {
float var2 = this.getCelestialAngle(par1);
float var3 = MathHelper.cos(var2 * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
@@ -1736,7 +1782,7 @@
{
int var5 = var3.getBlockID(par1, var4, par2);
@ -102,7 +149,20 @@
{
return var4 + 1;
}
@@ -1893,7 +1922,7 @@
@@ -1751,6 +1797,12 @@
* How bright are stars in the sky
*/
public float getStarBrightness(float par1)
+ {
+ return provider.getStarBrightness(par1);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public float getStarBrightnessBody(float par1)
{
float var2 = this.getCelestialAngle(par1);
float var3 = 1.0F - (MathHelper.cos(var2 * (float)Math.PI * 2.0F) * 2.0F + 0.25F);
@@ -1893,7 +1945,7 @@
if (var8 != null)
{
@ -111,7 +171,7 @@
}
}
}
@@ -1903,6 +1932,10 @@
@@ -1903,6 +1955,10 @@
if (!this.entityRemoval.isEmpty())
{
@ -122,7 +182,7 @@
this.loadedTileEntityList.removeAll(this.entityRemoval);
this.entityRemoval.clear();
}
@@ -1923,7 +1956,9 @@
@@ -1923,7 +1979,9 @@
{
this.loadedTileEntityList.add(var9);
}
@ -133,7 +193,7 @@
if (this.chunkExists(var9.xCoord >> 4, var9.zCoord >> 4))
{
Chunk var10 = this.getChunkFromChunkCoords(var9.xCoord >> 4, var9.zCoord >> 4);
@@ -1933,8 +1968,6 @@
@@ -1933,8 +1991,6 @@
var10.setChunkBlockTileEntity(var9.xCoord & 15, var9.yCoord, var9.zCoord & 15, var9);
}
}
@ -142,7 +202,7 @@
}
}
@@ -1947,13 +1980,13 @@
@@ -1947,13 +2003,13 @@
public void addTileEntity(Collection par1Collection)
{
@ -163,7 +223,7 @@
}
}
@@ -1974,8 +2007,14 @@
@@ -1974,8 +2030,14 @@
int var3 = MathHelper.floor_double(par1Entity.posX);
int var4 = MathHelper.floor_double(par1Entity.posZ);
byte var5 = 32;
@ -180,7 +240,7 @@
{
par1Entity.lastTickPosX = par1Entity.posX;
par1Entity.lastTickPosY = par1Entity.posY;
@@ -2210,6 +2249,14 @@
@@ -2210,6 +2272,14 @@
{
return true;
}
@ -195,7 +255,7 @@
}
}
}
@@ -2516,25 +2563,21 @@
@@ -2516,25 +2586,21 @@
*/
public void setBlockTileEntity(int par1, int par2, int par3, TileEntity par4TileEntity)
{
@ -236,7 +296,7 @@
}
}
@@ -2543,27 +2586,10 @@
@@ -2543,27 +2609,10 @@
*/
public void removeBlockTileEntity(int par1, int par2, int par3)
{
@ -268,7 +328,7 @@
}
}
@@ -2589,7 +2615,8 @@
@@ -2589,7 +2638,8 @@
*/
public boolean isBlockNormalCube(int par1, int par2, int par3)
{
@ -278,7 +338,7 @@
}
/**
@@ -2597,8 +2624,7 @@
@@ -2597,8 +2647,7 @@
*/
public boolean doesBlockHaveSolidTopSurface(int par1, int par2, int par3)
{
@ -288,7 +348,7 @@
}
/**
@@ -2614,7 +2640,7 @@
@@ -2614,7 +2663,7 @@
if (var5 != null && !var5.isEmpty())
{
Block var6 = Block.blocksList[this.getBlockId(par1, par2, par3)];
@ -297,7 +357,74 @@
}
else
{
@@ -3041,7 +3067,7 @@
@@ -2645,8 +2694,7 @@
*/
public void setAllowedSpawnTypes(boolean par1, boolean par2)
{
- this.spawnHostileMobs = par1;
- this.spawnPeacefulMobs = par2;
+ provider.setAllowedSpawnTypes(par1, par2);
}
/**
@@ -2662,6 +2710,11 @@
*/
private void calculateInitialWeather()
{
+ provider.calculateInitialWeather();
+ }
+
+ public void calculateInitialWeatherBody()
+ {
if (this.worldInfo.isRaining())
{
this.rainingStrength = 1.0F;
@@ -2677,6 +2730,11 @@
* Updates all weather states.
*/
protected void updateWeather()
+ {
+ provider.updateWeather();
+ }
+
+ public void updateWeatherBody()
{
if (!this.provider.hasNoSky)
{
@@ -2779,7 +2837,7 @@
public void toggleRain()
{
- this.worldInfo.setRainTime(1);
+ provider.toggleRain();
}
protected void setActivePlayerChunksAndCheckLight()
@@ -2891,6 +2949,11 @@
*/
public boolean canBlockFreeze(int par1, int par2, int par3, boolean par4)
{
+ return provider.canBlockFreeze(par1, par2, par3, par4);
+ }
+
+ public boolean canBlockFreezeBody(int par1, int par2, int par3, boolean par4)
+ {
BiomeGenBase var5 = this.getBiomeGenForCoords(par1, par3);
float var6 = var5.getFloatTemperature();
@@ -2948,6 +3011,11 @@
* Tests whether or not snow can be placed at a given location
*/
public boolean canSnowAt(int par1, int par2, int par3)
+ {
+ return provider.canSnowAt(par1, par2, par3);
+ }
+
+ public boolean canSnowAtBody(int par1, int par2, int par3)
{
BiomeGenBase var4 = this.getBiomeGenForCoords(par1, par3);
float var5 = var4.getFloatTemperature();
@@ -3041,7 +3109,7 @@
private int computeBlockLightValue(int par1, int par2, int par3, int par4, int par5, int par6)
{
@ -306,7 +433,7 @@
int var8 = 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;
@@ -3309,10 +3335,10 @@
@@ -3309,10 +3377,10 @@
public List getEntitiesWithinAABBExcludingEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB)
{
this.entitiesWithinAABBExcludingEntity.clear();
@ -321,7 +448,7 @@
for (int var7 = var3; var7 <= var4; ++var7)
{
@@ -3333,10 +3359,10 @@
@@ -3333,10 +3401,10 @@
*/
public List getEntitiesWithinAABB(Class par1Class, AxisAlignedBB par2AxisAlignedBB)
{
@ -336,7 +463,7 @@
ArrayList var7 = new ArrayList();
for (int var8 = var3; var8 <= var4; ++var8)
@@ -3425,11 +3451,14 @@
@@ -3425,11 +3493,14 @@
*/
public void addLoadedEntities(List par1List)
{
@ -354,7 +481,7 @@
}
}
@@ -3466,7 +3495,10 @@
@@ -3466,7 +3537,10 @@
{
var9 = null;
}
@ -366,7 +493,47 @@
return par1 > 0 && var9 == null && var10.canPlaceBlockOnSide(this, par2, par3, par4, par6);
}
}
@@ -3707,7 +3739,10 @@
@@ -3656,7 +3730,7 @@
*/
public void setWorldTime(long par1)
{
- this.worldInfo.setWorldTime(par1);
+ provider.setWorldTime(par1);
}
/**
@@ -3664,12 +3738,12 @@
*/
public long getSeed()
{
- return this.worldInfo.getSeed();
+ return provider.getSeed();
}
public long getWorldTime()
{
- return this.worldInfo.getWorldTime();
+ return provider.getWorldTime();
}
/**
@@ -3677,13 +3751,13 @@
*/
public ChunkCoordinates getSpawnPoint()
{
- return new ChunkCoordinates(this.worldInfo.getSpawnX(), this.worldInfo.getSpawnY(), this.worldInfo.getSpawnZ());
+ return provider.getSpawnPoint();
}
@SideOnly(Side.CLIENT)
public void setSpawnLocation(int par1, int par2, int par3)
{
- this.worldInfo.setSpawnPosition(par1, par2, par3);
+ provider.setSpawnPoint(par1, par2, par3);
}
@SideOnly(Side.CLIENT)
@@ -3707,7 +3781,10 @@
if (!this.loadedEntityList.contains(par1Entity))
{
@ -378,7 +545,56 @@
}
}
@@ -3964,4 +3999,65 @@
@@ -3715,6 +3792,11 @@
* 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)
+ {
+ return provider.canMineBlock(par1EntityPlayer, par2, par3, par4);
+ }
+
+ public boolean canMineBlockBody(EntityPlayer par1EntityPlayer, int par2, int par3, int par4)
{
return true;
}
@@ -3827,8 +3909,7 @@
*/
public boolean isBlockHighHumidity(int par1, int par2, int par3)
{
- BiomeGenBase var4 = this.getBiomeGenForCoords(par1, par3);
- return var4.isHighHumidity();
+ return provider.isBlockHighHumidity(par1, par2, par3);
}
/**
@@ -3882,7 +3963,7 @@
*/
public int getHeight()
{
- return 256;
+ return provider.getHeight();
}
/**
@@ -3890,7 +3971,7 @@
*/
public int getActualHeight()
{
- return this.provider.hasNoSky ? 128 : 256;
+ return provider.getActualHeight();
}
/**
@@ -3936,7 +4017,7 @@
*/
public double getHorizon()
{
- return this.worldInfo.getTerrainType().getHorizon(this);
+ return provider.getHorizon();
}
/**
@@ -3964,4 +4045,65 @@
var7.destroyBlockPartially(par1, par2, par3, par4, par5);
}
}

View File

@ -26,7 +26,7 @@
}
@SideOnly(Side.CLIENT)
@@ -254,4 +258,110 @@
@@ -254,4 +258,241 @@
* Returns the dimension's name, e.g. "The End", "Nether", or "Overworld".
*/
public abstract String getDimensionName();
@ -135,5 +135,136 @@
+ }
+
+ return var5;
+ }
+
+
+ /*======================================= Start Moved From World =========================================*/
+
+ public BiomeGenBase getBiomeGenForCoords(int x, int z)
+ {
+ return worldObj.getBiomeGenForCoordsBody(x, z);
+ }
+
+ public boolean isDaytime()
+ {
+ return worldObj.skylightSubtracted < 4;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public Vec3 getSkyColor(Entity cameraEntity, float partialTicks)
+ {
+ return worldObj.getSkyColorBody(cameraEntity, partialTicks);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public Vec3 drawClouds(float partialTicks)
+ {
+ return worldObj.drawCloudsBody(partialTicks);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public float getStarBrightness(float par1)
+ {
+ return worldObj.getStarBrightnessBody(par1);
+ }
+
+ public void setAllowedSpawnTypes(boolean allowHostile, boolean allowPeaceful)
+ {
+ worldObj.spawnHostileMobs = allowHostile;
+ worldObj.spawnPeacefulMobs = allowPeaceful;
+ }
+
+ public void calculateInitialWeather()
+ {
+ worldObj.calculateInitialWeatherBody();
+ }
+
+ public void updateWeather()
+ {
+ worldObj.updateWeatherBody();
+ }
+
+ public void toggleRain()
+ {
+ worldObj.worldInfo.setRainTime(1);
+ }
+
+ public boolean canBlockFreeze(int x, int y, int z, boolean byWater)
+ {
+ return worldObj.canBlockFreezeBody(x, y, z, byWater);
+ }
+
+ public boolean canSnowAt(int x, int y, int z)
+ {
+ return worldObj.canSnowAtBody(x, y, z);
+ }
+
+ public void setWorldTime(long time)
+ {
+ worldObj.worldInfo.setWorldTime(time);
+ }
+
+ public long getSeed()
+ {
+ return worldObj.worldInfo.getSeed();
+ }
+
+ public long getWorldTime()
+ {
+ return worldObj.worldInfo.getWorldTime();
+ }
+
+ public ChunkCoordinates getSpawnPoint()
+ {
+ WorldInfo info = worldObj.worldInfo;
+ return new ChunkCoordinates(info.getSpawnX(), info.getSpawnY(), info.getSpawnZ());
+ }
+
+ public void setSpawnPoint(int x, int y, int z)
+ {
+ worldObj.worldInfo.setSpawnPosition(x, y, z);
+ }
+
+ public boolean canMineBlock(EntityPlayer player, int x, int y, int z)
+ {
+ return worldObj.canMineBlockBody(player, x, y, z);
+ }
+
+ public boolean isBlockHighHumidity(int x, int y, int z)
+ {
+ return worldObj.getBiomeGenForCoords(x, z).isHighHumidity();
+ }
+
+ public int getHeight()
+ {
+ return 256;
+ }
+
+ public int getActualHeight()
+ {
+ return hasNoSky ? 128 : 256;
+ }
+
+ public double getHorizon()
+ {
+ return worldObj.worldInfo.getTerrainType().getHorizon(worldObj);
+ }
+
+ public void resetRainAndThunder()
+ {
+ worldObj.worldInfo.setRainTime(0);
+ worldObj.worldInfo.setRaining(false);
+ worldObj.worldInfo.setThunderTime(0);
+ worldObj.worldInfo.setThundering(false);
+ }
+
+ public boolean canDoLightning(Chunk chunk)
+ {
+ return true;
+ }
+
+ public boolean canDoRainSnowIce(Chunk chunk)
+ {
+ return true;
+ }
}

View File

@ -18,7 +18,37 @@
}
/**
@@ -559,15 +563,27 @@
@@ -179,10 +183,7 @@
private void resetRainAndThunder()
{
- this.worldInfo.setRainTime(0);
- this.worldInfo.setRaining(false);
- this.worldInfo.setThunderTime(0);
- this.worldInfo.setThundering(false);
+ provider.resetRainAndThunder();
}
public boolean areAllPlayersAsleep()
@@ -270,7 +271,7 @@
int var10;
int var11;
- if (this.rand.nextInt(100000) == 0 && this.isRaining() && this.isThundering())
+ if (provider.canDoLightning(var7) && this.rand.nextInt(100000) == 0 && this.isRaining() && this.isThundering())
{
this.updateLCG = this.updateLCG * 3 + 1013904223;
var8 = this.updateLCG >> 2;
@@ -288,7 +289,7 @@
this.theProfiler.endStartSection("iceandsnow");
int var13;
- if (this.rand.nextInt(16) == 0)
+ if (provider.canDoRainSnowIce(var7) && this.rand.nextInt(16) == 0)
{
this.updateLCG = this.updateLCG * 3 + 1013904223;
var8 = this.updateLCG >> 2;
@@ -559,15 +560,27 @@
public List getAllTileEntityInBox(int par1, int par2, int par3, int par4, int par5, int par6)
{
ArrayList var7 = new ArrayList();
@ -55,7 +85,19 @@
}
}
@@ -587,7 +603,7 @@
@@ -578,6 +591,11 @@
* 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)
+ {
+ return super.canMineBlock(par1EntityPlayer, par2, par3, par4);
+ }
+
+ public boolean canMineBlockBody(EntityPlayer par1EntityPlayer, int par2, int par3, int par4)
{
int var5 = MathHelper.abs_int(par2 - this.worldInfo.getSpawnX());
int var6 = MathHelper.abs_int(par4 - this.worldInfo.getSpawnZ());
@@ -587,7 +605,7 @@
var6 = var5;
}
@ -64,7 +106,7 @@
}
protected void initialize(WorldSettings par1WorldSettings)
@@ -713,6 +729,7 @@
@@ -713,6 +731,7 @@
}
this.chunkProvider.saveChunks(par1, par2IProgressUpdate);

View File

@ -0,0 +1,15 @@
--- ../src_base/minecraft/net/minecraft/src/WorldClient.java
+++ ../src_work/minecraft/net/minecraft/src/WorldClient.java
@@ -265,6 +265,12 @@
*/
protected void updateWeather()
{
+ super.updateWeather();
+ }
+
+ @Override
+ public void updateWeatherBody()
+ {
if (!this.provider.hasNoSky)
{
if (this.lastLightningBolt > 0)