mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-27 15:33:18 +00:00
808 lines
29 KiB
Diff
808 lines
29 KiB
Diff
--- ../src_base/minecraft/net/minecraft/world/World.java
|
|
+++ ../src_work/minecraft/net/minecraft/world/World.java
|
|
@@ -47,8 +47,30 @@
|
|
import net.minecraft.world.storage.MapStorage;
|
|
import net.minecraft.world.storage.WorldInfo;
|
|
|
|
+import com.google.common.collect.ImmutableSetMultimap;
|
|
+
|
|
+import net.minecraftforge.common.ForgeChunkManager;
|
|
+import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
|
+import net.minecraftforge.common.ForgeHooks;
|
|
+import net.minecraftforge.common.MinecraftForge;
|
|
+import net.minecraftforge.common.ForgeDirection;
|
|
+import net.minecraftforge.common.WorldSpecificSaveHandler;
|
|
+import net.minecraftforge.event.entity.EntityEvent;
|
|
+import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
|
+import net.minecraftforge.event.world.WorldEvent;
|
|
+import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
|
|
+
|
|
public abstract class World implements IBlockAccess
|
|
{
|
|
+ /**
|
|
+ * Used in the getEntitiesWithinAABB functions to expand the search area for entities.
|
|
+ * Modders should change this variable to a higher value if it is less then the radius
|
|
+ * of one of there entities.
|
|
+ */
|
|
+ public static double MAX_ENTITY_RADIUS = 2.0D;
|
|
+
|
|
+ public final MapStorage perWorldStorage;
|
|
+
|
|
/**
|
|
* boolean; if true updates scheduled by scheduleBlockUpdate happen immediately
|
|
*/
|
|
@@ -162,6 +184,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))
|
|
{
|
|
@@ -192,7 +219,13 @@
|
|
this.theProfiler = par5Profiler;
|
|
this.worldInfo = new WorldInfo(par4WorldSettings, par2Str);
|
|
this.provider = par3WorldProvider;
|
|
- this.mapStorage = new MapStorage(par1ISaveHandler);
|
|
+ perWorldStorage = new MapStorage((ISaveHandler)null);
|
|
+ }
|
|
+
|
|
+ // Broken up so that the WorldClient gets the chance to set the mapstorage object before the dimension initializes
|
|
+ @SideOnly(Side.CLIENT)
|
|
+ protected void finishSetup()
|
|
+ {
|
|
VillageCollection villagecollection = (VillageCollection)this.mapStorage.loadData(VillageCollection.class, "villages");
|
|
|
|
if (villagecollection == null)
|
|
@@ -206,7 +239,7 @@
|
|
this.villageCollectionObj.func_82566_a(this);
|
|
}
|
|
|
|
- par3WorldProvider.registerWorld(this);
|
|
+ this.provider.registerWorld(this);
|
|
this.chunkProvider = this.createChunkProvider();
|
|
this.calculateInitialSkylight();
|
|
this.calculateInitialWeather();
|
|
@@ -220,7 +253,7 @@
|
|
this.isRemote = false;
|
|
this.saveHandler = par1ISaveHandler;
|
|
this.theProfiler = par5Profiler;
|
|
- this.mapStorage = new MapStorage(par1ISaveHandler);
|
|
+ this.mapStorage = getMapStorage(par1ISaveHandler);
|
|
this.worldInfo = par1ISaveHandler.loadWorldInfo();
|
|
|
|
if (par4WorldProvider != null)
|
|
@@ -273,12 +306,20 @@
|
|
this.worldInfo.setServerInitialized(true);
|
|
}
|
|
|
|
- VillageCollection villagecollection = (VillageCollection)this.mapStorage.loadData(VillageCollection.class, "villages");
|
|
+ if (this instanceof WorldServer)
|
|
+ {
|
|
+ this.perWorldStorage = new MapStorage(new WorldSpecificSaveHandler((WorldServer)this, par1ISaveHandler));
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ this.perWorldStorage = new MapStorage((ISaveHandler)null);
|
|
+ }
|
|
+ VillageCollection villagecollection = (VillageCollection)perWorldStorage.loadData(VillageCollection.class, "villages");
|
|
|
|
if (villagecollection == null)
|
|
{
|
|
this.villageCollectionObj = new VillageCollection(this);
|
|
- this.mapStorage.setData("villages", this.villageCollectionObj);
|
|
+ this.perWorldStorage.setData("villages", this.villageCollectionObj);
|
|
}
|
|
else
|
|
{
|
|
@@ -288,6 +329,19 @@
|
|
|
|
this.calculateInitialSkylight();
|
|
this.calculateInitialWeather();
|
|
+ }
|
|
+
|
|
+ private static MapStorage s_mapStorage;
|
|
+ private static ISaveHandler s_savehandler;
|
|
+ //Provides a solution for different worlds getting different copies of the same data, potentially rewriting the data or causing race conditions/stale data
|
|
+ //Buildcraft has suffered from the issue this fixes. If you load the same data from two different worlds they can get two different copies of the same object, thus the last saved gets final say.
|
|
+ private MapStorage getMapStorage(ISaveHandler savehandler)
|
|
+ {
|
|
+ if (s_savehandler != savehandler || s_mapStorage == null) {
|
|
+ s_mapStorage = new MapStorage(savehandler);
|
|
+ s_savehandler = savehandler;
|
|
+ }
|
|
+ return s_mapStorage;
|
|
}
|
|
|
|
/**
|
|
@@ -376,7 +430,8 @@
|
|
*/
|
|
public boolean isAirBlock(int par1, int par2, int par3)
|
|
{
|
|
- return this.getBlockId(par1, par2, par3) == 0;
|
|
+ int id = getBlockId(par1, par2, par3);
|
|
+ return id == 0 || Block.blocksList[id] == null || Block.blocksList[id].isAirBlock(this, par1, par2, par3);
|
|
}
|
|
|
|
/**
|
|
@@ -385,7 +440,8 @@
|
|
public boolean blockHasTileEntity(int par1, int par2, int par3)
|
|
{
|
|
int l = this.getBlockId(par1, par2, par3);
|
|
- return Block.blocksList[l] != null && Block.blocksList[l].hasTileEntity();
|
|
+ int meta = this.getBlockMetadata(par1, par2, par3);
|
|
+ return Block.blocksList[l] != null && Block.blocksList[l].hasTileEntity(meta);
|
|
}
|
|
|
|
/**
|
|
@@ -1085,7 +1141,7 @@
|
|
*/
|
|
public boolean isDaytime()
|
|
{
|
|
- return this.skylightSubtracted < 4;
|
|
+ return provider.isDaytime();
|
|
}
|
|
|
|
/**
|
|
@@ -1117,7 +1173,7 @@
|
|
int l1 = this.getBlockMetadata(l, i1, j1);
|
|
Block block = Block.blocksList[k1];
|
|
|
|
- if ((!par4 || block == null || block.getCollisionBoundingBoxFromPool(this, l, i1, j1) != null) && k1 > 0 && block.canCollideCheck(l1, par3))
|
|
+ if (block != null && (!par4 || block == null || block.getCollisionBoundingBoxFromPool(this, l, i1, j1) != null) && k1 > 0 && block.canCollideCheck(l1, par3))
|
|
{
|
|
MovingObjectPosition movingobjectposition = block.collisionRayTrace(this, l, i1, j1, par1Vec3, par2Vec3);
|
|
|
|
@@ -1317,6 +1373,12 @@
|
|
*/
|
|
public void playSoundAtEntity(Entity par1Entity, String par2Str, float par3, float par4)
|
|
{
|
|
+ PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(par1Entity, par2Str, par3, par4);
|
|
+ if (MinecraftForge.EVENT_BUS.post(event))
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+ par2Str = event.name;
|
|
if (par1Entity != null && par2Str != null)
|
|
{
|
|
for (int i = 0; i < this.worldAccesses.size(); ++i)
|
|
@@ -1331,6 +1393,12 @@
|
|
*/
|
|
public void playSoundToNearExcept(EntityPlayer par1EntityPlayer, String par2Str, float par3, float par4)
|
|
{
|
|
+ PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(par1EntityPlayer, par2Str, par3, par4);
|
|
+ if (MinecraftForge.EVENT_BUS.post(event))
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+ par2Str = event.name;
|
|
if (par1EntityPlayer != null && par2Str != null)
|
|
{
|
|
for (int i = 0; i < this.worldAccesses.size(); ++i)
|
|
@@ -1417,6 +1485,11 @@
|
|
EntityPlayer entityplayer = (EntityPlayer)par1Entity;
|
|
this.playerEntities.add(entityplayer);
|
|
this.updateAllPlayersSleepingFlag();
|
|
+ }
|
|
+
|
|
+ if (!flag && MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(par1Entity, this)))
|
|
+ {
|
|
+ return false;
|
|
}
|
|
|
|
this.getChunkFromChunkCoords(i, j).addEntity(par1Entity);
|
|
@@ -1663,6 +1736,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 f1 = this.getCelestialAngle(par2);
|
|
float f2 = MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
|
|
@@ -1756,6 +1835,12 @@
|
|
@SideOnly(Side.CLIENT)
|
|
public Vec3 drawClouds(float par1)
|
|
{
|
|
+ return provider.drawClouds(par1);
|
|
+ }
|
|
+
|
|
+ @SideOnly(Side.CLIENT)
|
|
+ public Vec3 drawCloudsBody(float par1)
|
|
+ {
|
|
float f1 = this.getCelestialAngle(par1);
|
|
float f2 = MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
|
|
|
|
@@ -1834,7 +1919,7 @@
|
|
{
|
|
int l = chunk.getBlockID(par1, k, par2);
|
|
|
|
- if (l != 0 && Block.blocksList[l].blockMaterial.blocksMovement() && Block.blocksList[l].blockMaterial != Material.leaves)
|
|
+ if (l != 0 && Block.blocksList[l].blockMaterial.blocksMovement() && Block.blocksList[l].blockMaterial != Material.leaves && !Block.blocksList[l].isBlockFoliage(this, par1, k, par2))
|
|
{
|
|
return k + 1;
|
|
}
|
|
@@ -1849,6 +1934,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 f1 = this.getCelestialAngle(par1);
|
|
float f2 = 1.0F - (MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.25F);
|
|
@@ -1984,16 +2075,8 @@
|
|
|
|
if (entity.isDead)
|
|
{
|
|
- j = entity.chunkCoordX;
|
|
- k = entity.chunkCoordZ;
|
|
-
|
|
- if (entity.addedToChunk && this.chunkExists(j, k))
|
|
- {
|
|
- this.getChunkFromChunkCoords(j, k).removeEntity(entity);
|
|
- }
|
|
-
|
|
- this.loadedEntityList.remove(i--);
|
|
- this.releaseEntitySkin(entity);
|
|
+ // If it's dead, move it to the unloaded list for removal on the next tick
|
|
+ unloadedEntityList.add(entity);
|
|
}
|
|
|
|
this.theProfiler.endSection();
|
|
@@ -2032,7 +2115,7 @@
|
|
|
|
if (chunk != null)
|
|
{
|
|
- chunk.removeChunkBlockTileEntity(tileentity.xCoord & 15, tileentity.yCoord, tileentity.zCoord & 15);
|
|
+ chunk.cleanChunkBlockTileEntity(tileentity.xCoord & 15, tileentity.yCoord, tileentity.zCoord & 15);
|
|
}
|
|
}
|
|
}
|
|
@@ -2041,6 +2124,10 @@
|
|
|
|
if (!this.entityRemoval.isEmpty())
|
|
{
|
|
+ for (Object tile : entityRemoval)
|
|
+ {
|
|
+ ((TileEntity)tile).onChunkUnload();
|
|
+ }
|
|
this.loadedTileEntityList.removeAll(this.entityRemoval);
|
|
this.entityRemoval.clear();
|
|
}
|
|
@@ -2061,18 +2148,18 @@
|
|
{
|
|
this.loadedTileEntityList.add(tileentity1);
|
|
}
|
|
-
|
|
+ }
|
|
+ else
|
|
+ {
|
|
if (this.chunkExists(tileentity1.xCoord >> 4, tileentity1.zCoord >> 4))
|
|
{
|
|
Chunk chunk1 = this.getChunkFromChunkCoords(tileentity1.xCoord >> 4, tileentity1.zCoord >> 4);
|
|
|
|
if (chunk1 != null)
|
|
{
|
|
- chunk1.setChunkBlockTileEntity(tileentity1.xCoord & 15, tileentity1.yCoord, tileentity1.zCoord & 15, tileentity1);
|
|
+ chunk1.cleanChunkBlockTileEntity(tileentity1.xCoord & 15, tileentity1.yCoord, tileentity1.zCoord & 15);
|
|
}
|
|
}
|
|
-
|
|
- this.markBlockForUpdate(tileentity1.xCoord, tileentity1.yCoord, tileentity1.zCoord);
|
|
}
|
|
}
|
|
|
|
@@ -2085,13 +2172,13 @@
|
|
|
|
public void addTileEntity(Collection par1Collection)
|
|
{
|
|
- if (this.scanningTileEntities)
|
|
- {
|
|
- this.addedTileEntityList.addAll(par1Collection);
|
|
- }
|
|
- else
|
|
- {
|
|
- this.loadedTileEntityList.addAll(par1Collection);
|
|
+ List dest = scanningTileEntities ? addedTileEntityList : loadedTileEntityList;
|
|
+ for(Object entity : par1Collection)
|
|
+ {
|
|
+ if(((TileEntity)entity).canUpdate())
|
|
+ {
|
|
+ dest.add(entity);
|
|
+ }
|
|
}
|
|
}
|
|
|
|
@@ -2111,9 +2198,17 @@
|
|
{
|
|
int i = MathHelper.floor_double(par1Entity.posX);
|
|
int j = MathHelper.floor_double(par1Entity.posZ);
|
|
- byte b0 = 32;
|
|
-
|
|
- if (!par2 || this.checkChunksExist(i - b0, 0, j - b0, i + b0, 0, j + b0))
|
|
+
|
|
+ boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(i >> 4, j >> 4));
|
|
+ byte b0 = isForced ? (byte)0 : 32;
|
|
+ boolean canUpdate = !par2 || this.checkChunksExist(i - b0, 0, j - b0, i + b0, 0, j + b0);
|
|
+ if (!canUpdate)
|
|
+ {
|
|
+ EntityEvent.CanUpdate event = new EntityEvent.CanUpdate(par1Entity);
|
|
+ MinecraftForge.EVENT_BUS.post(event);
|
|
+ canUpdate = event.canUpdate;
|
|
+ }
|
|
+ if (canUpdate)
|
|
{
|
|
par1Entity.lastTickPosX = par1Entity.posX;
|
|
par1Entity.lastTickPosY = par1Entity.posY;
|
|
@@ -2346,6 +2441,14 @@
|
|
{
|
|
return true;
|
|
}
|
|
+ else
|
|
+ {
|
|
+ Block block = Block.blocksList[j2];
|
|
+ if (block != null && block.isBlockBurning(this, k1, l1, i2))
|
|
+ {
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
@@ -2651,25 +2754,21 @@
|
|
*/
|
|
public void setBlockTileEntity(int par1, int par2, int par3, TileEntity par4TileEntity)
|
|
{
|
|
- if (par4TileEntity != null && !par4TileEntity.isInvalid())
|
|
- {
|
|
- if (this.scanningTileEntities)
|
|
- {
|
|
- par4TileEntity.xCoord = par1;
|
|
- par4TileEntity.yCoord = par2;
|
|
- par4TileEntity.zCoord = par3;
|
|
- this.addedTileEntityList.add(par4TileEntity);
|
|
- }
|
|
- else
|
|
- {
|
|
- this.loadedTileEntityList.add(par4TileEntity);
|
|
- Chunk chunk = this.getChunkFromChunkCoords(par1 >> 4, par3 >> 4);
|
|
-
|
|
- if (chunk != null)
|
|
- {
|
|
- chunk.setChunkBlockTileEntity(par1 & 15, par2, par3 & 15, par4TileEntity);
|
|
- }
|
|
- }
|
|
+ if (par4TileEntity == null || par4TileEntity.isInvalid())
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if (par4TileEntity.canUpdate())
|
|
+ {
|
|
+ List dest = scanningTileEntities ? addedTileEntityList : loadedTileEntityList;
|
|
+ dest.add(par4TileEntity);
|
|
+ }
|
|
+
|
|
+ Chunk chunk = getChunkFromChunkCoords(par1 >> 4, par3 >> 4);
|
|
+ if (chunk != null)
|
|
+ {
|
|
+ chunk.setChunkBlockTileEntity(par1 & 15, par2, par3 & 15, par4TileEntity);
|
|
}
|
|
}
|
|
|
|
@@ -2678,27 +2777,10 @@
|
|
*/
|
|
public void removeBlockTileEntity(int par1, int par2, int par3)
|
|
{
|
|
- TileEntity tileentity = this.getBlockTileEntity(par1, par2, par3);
|
|
-
|
|
- if (tileentity != null && this.scanningTileEntities)
|
|
- {
|
|
- tileentity.invalidate();
|
|
- this.addedTileEntityList.remove(tileentity);
|
|
- }
|
|
- else
|
|
- {
|
|
- if (tileentity != null)
|
|
- {
|
|
- this.addedTileEntityList.remove(tileentity);
|
|
- this.loadedTileEntityList.remove(tileentity);
|
|
- }
|
|
-
|
|
- Chunk chunk = this.getChunkFromChunkCoords(par1 >> 4, par3 >> 4);
|
|
-
|
|
- if (chunk != null)
|
|
- {
|
|
- chunk.removeChunkBlockTileEntity(par1 & 15, par2, par3 & 15);
|
|
- }
|
|
+ Chunk chunk = getChunkFromChunkCoords(par1 >> 4, par3 >> 4);
|
|
+ if (chunk != null)
|
|
+ {
|
|
+ chunk.removeChunkBlockTileEntity(par1 & 15, par2, par3 & 15);
|
|
}
|
|
}
|
|
|
|
@@ -2724,7 +2806,8 @@
|
|
*/
|
|
public boolean isBlockNormalCube(int par1, int par2, int par3)
|
|
{
|
|
- return Block.isNormalCube(this.getBlockId(par1, par2, par3));
|
|
+ Block block = Block.blocksList[getBlockId(par1, par2, par3)];
|
|
+ return block != null && block.isBlockNormalCube(this, par1, par2, par3);
|
|
}
|
|
|
|
public boolean func_85174_u(int par1, int par2, int par3)
|
|
@@ -2747,8 +2830,7 @@
|
|
*/
|
|
public boolean doesBlockHaveSolidTopSurface(int par1, int par2, int par3)
|
|
{
|
|
- Block block = Block.blocksList[this.getBlockId(par1, par2, par3)];
|
|
- return block == null ? false : (block.blockMaterial.isOpaque() && block.renderAsNormalBlock() ? true : (block instanceof BlockStairs ? (this.getBlockMetadata(par1, par2, par3) & 4) == 4 : (block instanceof BlockHalfSlab ? (this.getBlockMetadata(par1, par2, par3) & 8) == 8 : block instanceof BlockHopper)));
|
|
+ return isBlockSolidOnSide(par1, par2, par3, ForgeDirection.UP);
|
|
}
|
|
|
|
/**
|
|
@@ -2764,7 +2846,7 @@
|
|
if (chunk != null && !chunk.isEmpty())
|
|
{
|
|
Block block = Block.blocksList[this.getBlockId(par1, par2, par3)];
|
|
- return block == null ? false : block.blockMaterial.isOpaque() && block.renderAsNormalBlock();
|
|
+ return block == null ? false : isBlockNormalCube(par1, par2, par3);
|
|
}
|
|
else
|
|
{
|
|
@@ -2795,8 +2877,7 @@
|
|
*/
|
|
public void setAllowedSpawnTypes(boolean par1, boolean par2)
|
|
{
|
|
- this.spawnHostileMobs = par1;
|
|
- this.spawnPeacefulMobs = par2;
|
|
+ provider.setAllowedSpawnTypes(par1, par2);
|
|
}
|
|
|
|
/**
|
|
@@ -2812,6 +2893,11 @@
|
|
*/
|
|
private void calculateInitialWeather()
|
|
{
|
|
+ provider.calculateInitialWeather();
|
|
+ }
|
|
+
|
|
+ public void calculateInitialWeatherBody()
|
|
+ {
|
|
if (this.worldInfo.isRaining())
|
|
{
|
|
this.rainingStrength = 1.0F;
|
|
@@ -2827,6 +2913,11 @@
|
|
* Updates all weather states.
|
|
*/
|
|
protected void updateWeather()
|
|
+ {
|
|
+ provider.updateWeather();
|
|
+ }
|
|
+
|
|
+ public void updateWeatherBody()
|
|
{
|
|
if (!this.provider.hasNoSky)
|
|
{
|
|
@@ -2924,12 +3015,14 @@
|
|
|
|
public void toggleRain()
|
|
{
|
|
- this.worldInfo.setRainTime(1);
|
|
+ provider.toggleRain();
|
|
}
|
|
|
|
protected void setActivePlayerChunksAndCheckLight()
|
|
{
|
|
this.activeChunkSet.clear();
|
|
+ this.activeChunkSet.addAll(getPersistentChunks().keySet());
|
|
+
|
|
this.theProfiler.startSection("buildList");
|
|
int i;
|
|
EntityPlayer entityplayer;
|
|
@@ -3036,6 +3129,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 biomegenbase = this.getBiomeGenForCoords(par1, par3);
|
|
float f = biomegenbase.getFloatTemperature();
|
|
|
|
@@ -3093,6 +3191,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 biomegenbase = this.getBiomeGenForCoords(par1, par3);
|
|
float f = biomegenbase.getFloatTemperature();
|
|
@@ -3186,7 +3289,7 @@
|
|
|
|
private int computeBlockLightValue(int par1, int par2, int par3, int par4, int par5, int par6)
|
|
{
|
|
- int k1 = Block.lightValue[par5];
|
|
+ int k1 = (par5 == 0 || Block.blocksList[par5] == null ? 0 : Block.blocksList[par5].getLightValue(this, par2, par3, par4));
|
|
int l1 = this.getSavedLightValue(EnumSkyBlock.Block, par2 - 1, par3, par4) - par6;
|
|
int i2 = this.getSavedLightValue(EnumSkyBlock.Block, par2 + 1, par3, par4) - par6;
|
|
int j2 = this.getSavedLightValue(EnumSkyBlock.Block, par2, par3 - 1, par4) - par6;
|
|
@@ -3321,7 +3424,7 @@
|
|
int k4 = i2 + (i4 / 2 + 1) % 3 / 2 * l3;
|
|
int l4 = j2 + (i4 / 2 + 2) % 3 / 2 * l3;
|
|
l2 = this.getSavedLightValue(par1EnumSkyBlock, j4, k4, l4);
|
|
- int i5 = Block.lightOpacity[this.getBlockId(j4, k4, l4)];
|
|
+ int i5 = this.getBlockLightOpacity(j4, k4, l4);
|
|
|
|
if (i5 == 0)
|
|
{
|
|
@@ -3352,7 +3455,7 @@
|
|
j2 = (k1 >> 12 & 63) - 32 + par4;
|
|
k2 = this.getSavedLightValue(par1EnumSkyBlock, l1, i2, j2);
|
|
l2 = this.getBlockId(l1, i2, j2);
|
|
- i3 = Block.lightOpacity[l2];
|
|
+ i3 = this.getBlockLightOpacity(l1, i2, j2);
|
|
|
|
if (i3 == 0)
|
|
{
|
|
@@ -3459,10 +3562,10 @@
|
|
public List func_94576_a(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB, IEntitySelector par3IEntitySelector)
|
|
{
|
|
this.entitiesWithinAABBExcludingEntity.clear();
|
|
- int i = MathHelper.floor_double((par2AxisAlignedBB.minX - 2.0D) / 16.0D);
|
|
- int j = MathHelper.floor_double((par2AxisAlignedBB.maxX + 2.0D) / 16.0D);
|
|
- int k = MathHelper.floor_double((par2AxisAlignedBB.minZ - 2.0D) / 16.0D);
|
|
- int l = MathHelper.floor_double((par2AxisAlignedBB.maxZ + 2.0D) / 16.0D);
|
|
+ int i = MathHelper.floor_double((par2AxisAlignedBB.minX - MAX_ENTITY_RADIUS) / 16.0D);
|
|
+ int j = MathHelper.floor_double((par2AxisAlignedBB.maxX + MAX_ENTITY_RADIUS) / 16.0D);
|
|
+ int k = MathHelper.floor_double((par2AxisAlignedBB.minZ - MAX_ENTITY_RADIUS) / 16.0D);
|
|
+ int l = MathHelper.floor_double((par2AxisAlignedBB.maxZ + MAX_ENTITY_RADIUS) / 16.0D);
|
|
|
|
for (int i1 = i; i1 <= j; ++i1)
|
|
{
|
|
@@ -3488,10 +3591,10 @@
|
|
|
|
public List selectEntitiesWithinAABB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, IEntitySelector par3IEntitySelector)
|
|
{
|
|
- int i = MathHelper.floor_double((par2AxisAlignedBB.minX - 2.0D) / 16.0D);
|
|
- int j = MathHelper.floor_double((par2AxisAlignedBB.maxX + 2.0D) / 16.0D);
|
|
- int k = MathHelper.floor_double((par2AxisAlignedBB.minZ - 2.0D) / 16.0D);
|
|
- int l = MathHelper.floor_double((par2AxisAlignedBB.maxZ + 2.0D) / 16.0D);
|
|
+ int i = MathHelper.floor_double((par2AxisAlignedBB.minX - MAX_ENTITY_RADIUS) / 16.0D);
|
|
+ int j = MathHelper.floor_double((par2AxisAlignedBB.maxX + MAX_ENTITY_RADIUS) / 16.0D);
|
|
+ int k = MathHelper.floor_double((par2AxisAlignedBB.minZ - MAX_ENTITY_RADIUS) / 16.0D);
|
|
+ int l = MathHelper.floor_double((par2AxisAlignedBB.maxZ + MAX_ENTITY_RADIUS) / 16.0D);
|
|
ArrayList arraylist = new ArrayList();
|
|
|
|
for (int i1 = i; i1 <= j; ++i1)
|
|
@@ -3584,11 +3687,14 @@
|
|
*/
|
|
public void addLoadedEntities(List par1List)
|
|
{
|
|
- this.loadedEntityList.addAll(par1List);
|
|
-
|
|
for (int i = 0; i < par1List.size(); ++i)
|
|
{
|
|
- this.obtainEntitySkin((Entity)par1List.get(i));
|
|
+ Entity entity = (Entity)par1List.get(i);
|
|
+ if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this)))
|
|
+ {
|
|
+ loadedEntityList.add(entity);
|
|
+ this.obtainEntitySkin(entity);
|
|
+ }
|
|
}
|
|
}
|
|
|
|
@@ -3619,6 +3725,11 @@
|
|
else
|
|
{
|
|
if (block != null && (block == Block.waterMoving || block == Block.waterStill || block == Block.lavaMoving || block == Block.lavaStill || block == Block.fire || block.blockMaterial.isReplaceable()))
|
|
+ {
|
|
+ block = null;
|
|
+ }
|
|
+
|
|
+ if (block != null && block.isBlockReplaceable(this, par2, par3, par4))
|
|
{
|
|
block = null;
|
|
}
|
|
@@ -3907,7 +4018,7 @@
|
|
*/
|
|
public long getSeed()
|
|
{
|
|
- return this.worldInfo.getSeed();
|
|
+ return provider.getSeed();
|
|
}
|
|
|
|
public long getTotalWorldTime()
|
|
@@ -3917,7 +4028,7 @@
|
|
|
|
public long getWorldTime()
|
|
{
|
|
- return this.worldInfo.getWorldTime();
|
|
+ return provider.getWorldTime();
|
|
}
|
|
|
|
/**
|
|
@@ -3925,7 +4036,7 @@
|
|
*/
|
|
public void setWorldTime(long par1)
|
|
{
|
|
- this.worldInfo.setWorldTime(par1);
|
|
+ provider.setWorldTime(par1);
|
|
}
|
|
|
|
/**
|
|
@@ -3933,13 +4044,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)
|
|
@@ -3963,7 +4074,10 @@
|
|
|
|
if (!this.loadedEntityList.contains(par1Entity))
|
|
{
|
|
- this.loadedEntityList.add(par1Entity);
|
|
+ if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(par1Entity, this)))
|
|
+ {
|
|
+ loadedEntityList.add(par1Entity);
|
|
+ }
|
|
}
|
|
}
|
|
|
|
@@ -3971,6 +4085,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;
|
|
}
|
|
@@ -4091,8 +4210,7 @@
|
|
*/
|
|
public boolean isBlockHighHumidity(int par1, int par2, int par3)
|
|
{
|
|
- BiomeGenBase biomegenbase = this.getBiomeGenForCoords(par1, par3);
|
|
- return biomegenbase.isHighHumidity();
|
|
+ return provider.isBlockHighHumidity(par1, par2, par3);
|
|
}
|
|
|
|
/**
|
|
@@ -4167,7 +4285,7 @@
|
|
*/
|
|
public int getHeight()
|
|
{
|
|
- return 256;
|
|
+ return provider.getHeight();
|
|
}
|
|
|
|
/**
|
|
@@ -4175,7 +4293,7 @@
|
|
*/
|
|
public int getActualHeight()
|
|
{
|
|
- return this.provider.hasNoSky ? 128 : 256;
|
|
+ return provider.getActualHeight();
|
|
}
|
|
|
|
public IUpdatePlayerListBox func_82735_a(EntityMinecart par1EntityMinecart)
|
|
@@ -4218,7 +4336,7 @@
|
|
*/
|
|
public double getHorizon()
|
|
{
|
|
- return this.worldInfo.getTerrainType().getHorizon(this);
|
|
+ return provider.getHorizon();
|
|
}
|
|
|
|
/**
|
|
@@ -4279,4 +4397,75 @@
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public void func_92088_a(double par1, double par3, double par5, double par7, double par9, double par11, NBTTagCompound par13NBTTagCompound) {}
|
|
+
|
|
+ /**
|
|
+ * Adds a single TileEntity to the world.
|
|
+ * @param entity The TileEntity to be added.
|
|
+ */
|
|
+ public void addTileEntity(TileEntity entity)
|
|
+ {
|
|
+ List dest = scanningTileEntities ? addedTileEntityList : loadedTileEntityList;
|
|
+ if(entity.canUpdate())
|
|
+ {
|
|
+ dest.add(entity);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Determine if the given block is considered solid on the
|
|
+ * specified side. Used by placement logic.
|
|
+ *
|
|
+ * @param x Block X Position
|
|
+ * @param y Block Y Position
|
|
+ * @param z Block Z Position
|
|
+ * @param side The Side in question
|
|
+ * @return True if the side is solid
|
|
+ */
|
|
+ public boolean isBlockSolidOnSide(int x, int y, int z, ForgeDirection side)
|
|
+ {
|
|
+ return isBlockSolidOnSide(x, y, z, side, false);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Determine if the given block is considered solid on the
|
|
+ * specified side. Used by placement logic.
|
|
+ *
|
|
+ * @param x Block X Position
|
|
+ * @param y Block Y Position
|
|
+ * @param z Block Z Position
|
|
+ * @param side The Side in question
|
|
+ * @param _default The defult to return if the block doesn't exist.
|
|
+ * @return True if the side is solid
|
|
+ */
|
|
+ public boolean isBlockSolidOnSide(int x, int y, int z, ForgeDirection side, boolean _default)
|
|
+ {
|
|
+ if (x < -30000000 || z < -30000000 || x >= 30000000 || z >= 30000000)
|
|
+ {
|
|
+ return _default;
|
|
+ }
|
|
+
|
|
+ Chunk chunk = this.chunkProvider.provideChunk(x >> 4, z >> 4);
|
|
+ if (chunk == null || chunk.isEmpty())
|
|
+ {
|
|
+ return _default;
|
|
+ }
|
|
+
|
|
+ Block block = Block.blocksList[getBlockId(x, y, z)];
|
|
+ if(block == null)
|
|
+ {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ return block.isBlockSolidOnSide(this, x, y, z, side);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get the persistent chunks for this world
|
|
+ *
|
|
+ * @return
|
|
+ */
|
|
+ public ImmutableSetMultimap<ChunkCoordIntPair, Ticket> getPersistentChunks()
|
|
+ {
|
|
+ return ForgeChunkManager.getPersistentChunksFor(this);
|
|
+ }
|
|
}
|