This commit is contained in:
RainWarrior 2016-03-02 20:28:51 +03:00
parent cff4bf21ae
commit becb0a9e0e
2 changed files with 116 additions and 109 deletions

View file

@ -1,10 +1,34 @@
--- ../src-base/minecraft/net/minecraft/world/chunk/Chunk.java
+++ ../src-work/minecraft/net/minecraft/world/chunk/Chunk.java
@@ -175,7 +175,7 @@
{
IBlockState iblockstate = this.func_186032_a(j, l - 1, k);
- if (iblockstate.func_185891_c() != 0)
+ if (iblockstate.getLightOpacity(this.worldObj, new BlockPos(j, l - 1, k)) != 0)
{
this.heightMap[k << 4 | j] = l;
@@ -448,12 +448,12 @@
public int getBlockLightOpacity(BlockPos pos)
{
- return this.getBlockState(pos).func_185891_c();
+ return this.getBlockState(pos).getLightOpacity(this.worldObj, pos);
}
private int getBlockLightOpacity(int x, int y, int z)
{
- return this.func_186032_a(x, y, z).func_185891_c();
+ return this.func_186032_a(x, y, z).getLightOpacity(this.worldObj, new BlockPos(x, y, z));
}
public IBlockState getBlockState(BlockPos pos)
@@ -534,6 +534,7 @@
{
Block block = state.getBlock();
Block block1 = iblockstate.getBlock();
+ int k1 = block1.getLightOpacity(this.worldObj, pos); // Relocate old light value lookup here, so that it is called before TE is removed.
+ int k1 = iblockstate.getLightOpacity(this.worldObj, pos); // Relocate old light value lookup here, so that it is called before TE is removed.
ExtendedBlockStorage extendedblockstorage = this.storageArrays[j >> 4];
boolean flag = false;
@ -30,7 +54,17 @@
this.worldObj.removeTileEntity(pos);
}
}
@@ -595,28 +601,18 @@
@@ -574,8 +580,7 @@
}
else
{
- int j1 = state.func_185891_c();
- int k1 = iblockstate.func_185891_c();
+ int j1 = state.getLightOpacity(this.worldObj, pos);
if (j1 > 0)
{
@@ -595,28 +600,18 @@
}
}
@ -61,7 +95,7 @@
this.worldObj.setTileEntity(pos, tileentity1);
}
@@ -719,6 +715,7 @@
@@ -719,6 +714,7 @@
k = this.entityLists.length - 1;
}
@ -69,7 +103,28 @@
entityIn.addedToChunk = true;
entityIn.chunkCoordX = this.xPosition;
entityIn.chunkCoordY = k;
@@ -774,14 +771,9 @@
@@ -758,13 +754,19 @@
{
IBlockState iblockstate = this.getBlockState(pos);
Block block = iblockstate.getBlock();
- return !block.hasTileEntity() ? null : ((ITileEntityProvider)block).createNewTileEntity(this.worldObj, iblockstate.getBlock().getMetaFromState(iblockstate));
+ return !block.hasTileEntity(iblockstate) ? null : block.createTileEntity(this.worldObj, iblockstate);
}
public TileEntity getTileEntity(BlockPos pos, Chunk.EnumCreateEntityType p_177424_2_)
{
TileEntity tileentity = (TileEntity)this.chunkTileEntityMap.get(pos);
+ if (tileentity != null && tileentity.isInvalid())
+ {
+ chunkTileEntityMap.remove(pos);
+ tileentity = null;
+ }
+
if (tileentity == null)
{
if (p_177424_2_ == Chunk.EnumCreateEntityType.IMMEDIATE)
@@ -774,14 +776,9 @@
}
else if (p_177424_2_ == Chunk.EnumCreateEntityType.QUEUED)
{
@ -85,7 +140,16 @@
return tileentity;
}
@@ -810,6 +802,7 @@
@@ -801,7 +798,7 @@
tileEntityIn.setWorldObj(this.worldObj);
tileEntityIn.setPos(pos);
- if (this.getBlockState(pos).getBlock() instanceof ITileEntityProvider)
+ if (this.getBlockState(pos).getBlock().hasTileEntity(this.getBlockState(pos)))
{
if (this.chunkTileEntityMap.containsKey(pos))
{
@@ -810,6 +807,7 @@
tileEntityIn.validate();
this.chunkTileEntityMap.put(pos, tileEntityIn);
@ -93,7 +157,7 @@
}
}
@@ -838,8 +831,9 @@
@@ -838,8 +836,9 @@
entity.onChunkLoad();
}
@ -104,7 +168,7 @@
}
public void onChunkUnload()
@@ -855,6 +849,7 @@
@@ -855,6 +854,7 @@
{
this.worldObj.unloadEntities(this.entityLists[i]);
}
@ -112,7 +176,7 @@
}
public void setChunkModified()
@@ -864,8 +859,8 @@
@@ -864,8 +864,8 @@
public void getEntitiesWithinAABBForEntity(Entity entityIn, AxisAlignedBB aabb, List<Entity> listToFill, Predicate <? super Entity > p_177414_4_)
{
@ -123,7 +187,7 @@
i = MathHelper.clamp_int(i, 0, this.entityLists.length - 1);
j = MathHelper.clamp_int(j, 0, this.entityLists.length - 1);
@@ -904,8 +899,8 @@
@@ -904,8 +904,8 @@
public <T extends Entity> void getEntitiesOfTypeWithinAAAB(Class <? extends T > entityClass, AxisAlignedBB aabb, List<T> listToFill, Predicate <? super T > p_177430_4_)
{
@ -134,7 +198,30 @@
i = MathHelper.clamp_int(i, 0, this.entityLists.length - 1);
j = MathHelper.clamp_int(j, 0, this.entityLists.length - 1);
@@ -1162,10 +1157,16 @@
@@ -1050,7 +1050,7 @@
{
BlockPos blockpos = (BlockPos)this.tileEntityPosQueue.poll();
- if (this.getTileEntity(blockpos, Chunk.EnumCreateEntityType.CHECK) == null && this.getBlockState(blockpos).getBlock().hasTileEntity())
+ if (this.getTileEntity(blockpos, Chunk.EnumCreateEntityType.CHECK) == null && this.getBlockState(blockpos).getBlock().hasTileEntity(this.getBlockState(blockpos)))
{
TileEntity tileentity = this.createNewTileEntity(blockpos);
this.worldObj.setTileEntity(blockpos, tileentity);
@@ -1114,6 +1114,13 @@
@SideOnly(Side.CLIENT)
public void func_186033_a(PacketBuffer p_186033_1_, int p_186033_2_, boolean p_186033_3_)
{
+ for(TileEntity tileEntity : chunkTileEntityMap.values())
+ {
+ tileEntity.updateContainingBlockInfo();
+ tileEntity.getBlockMetadata();
+ tileEntity.getBlockType();
+ }
+
boolean flag = !this.worldObj.provider.getHasNoSky();
for (int i = 0; i < this.storageArrays.length; ++i)
@@ -1162,10 +1169,16 @@
this.isTerrainPopulated = true;
this.generateHeightMap();
@ -151,7 +238,25 @@
}
public BiomeGenBase getBiome(BlockPos pos, BiomeProvider chunkManager)
@@ -1481,4 +1482,20 @@
@@ -1239,7 +1252,7 @@
{
BlockPos blockpos2 = blockpos1.offset(enumfacing);
- if (this.worldObj.getBlockState(blockpos2).func_185906_d() > 0)
+ if (this.worldObj.getBlockState(blockpos2).getLightValue(this.worldObj, blockpos2) > 0)
{
this.worldObj.checkLight(blockpos2);
}
@@ -1370,7 +1383,7 @@
{
blockpos$mutableblockpos.set(blockpos$mutableblockpos.getX(), l, blockpos$mutableblockpos.getZ());
- if (this.getBlockState(blockpos$mutableblockpos).func_185906_d() > 0)
+ if (this.getBlockState(blockpos$mutableblockpos).getLightValue(this.worldObj, blockpos$mutableblockpos) > 0)
{
this.worldObj.checkLight(blockpos$mutableblockpos);
}
@@ -1481,4 +1494,20 @@
QUEUED,
CHECK;
}

View file

@ -1,98 +0,0 @@
++++ REJECTED PATCH 1
{
Block block = this.getBlock0(j, l - 1, k);
- if (block.getLightOpacity() != 0)
+ if (getBlockLightOpacity(j, l - 1, k) != 0)
{
this.heightMap[k << 4 | j] = l;
++++ END PATCH
++++ REJECTED PATCH 2
public int getBlockLightOpacity(BlockPos pos)
{
- return this.getBlock(pos).getLightOpacity();
+ return this.getBlock(pos).getLightOpacity(worldObj, pos);
}
private int getBlockLightOpacity(int x, int y, int z)
{
- return this.getBlock0(x, y, z).getLightOpacity();
+ return getBlockLightOpacity(new BlockPos((xPosition << 4) + x, y, (zPosition << 4) + z));
}
private Block getBlock0(int x, int y, int z)
++++ END PATCH
++++ REJECTED PATCH 5
}
else
{
- int j1 = block.getLightOpacity();
- int k1 = block1.getLightOpacity();
+ int j1 = block.getLightOpacity(this.worldObj, pos);
if (j1 > 0)
{
++++ END PATCH
++++ REJECTED PATCH 8
private TileEntity createNewTileEntity(BlockPos pos)
{
Block block = this.getBlock(pos);
- return !block.hasTileEntity() ? null : ((ITileEntityProvider)block).createNewTileEntity(this.worldObj, this.getBlockMetadata(pos));
+ IBlockState state = block.getStateFromMeta(this.getBlockMetadata(pos));
+ return !block.hasTileEntity(state) ? null : block.createTileEntity(this.worldObj, state);
}
public TileEntity getTileEntity(BlockPos pos, Chunk.EnumCreateEntityType p_177424_2_)
{
TileEntity tileentity = (TileEntity)this.chunkTileEntityMap.get(pos);
+ if (tileentity != null && tileentity.isInvalid())
+ {
+ chunkTileEntityMap.remove(pos);
+ tileentity = null;
+ }
+
if (tileentity == null)
{
if (p_177424_2_ == Chunk.EnumCreateEntityType.IMMEDIATE)
++++ END PATCH
++++ REJECTED PATCH 10
tileEntityIn.setWorldObj(this.worldObj);
tileEntityIn.setPos(pos);
- if (this.getBlock(pos) instanceof ITileEntityProvider)
+ if (this.getBlock(pos).hasTileEntity(getBlock(pos).getStateFromMeta(this.getBlockMetadata(pos))))
{
if (this.chunkTileEntityMap.containsKey(pos))
{
++++ END PATCH
++++ REJECTED PATCH 16
while (!this.tileEntityPosQueue.isEmpty())
{
BlockPos blockpos = (BlockPos)this.tileEntityPosQueue.poll();
+ Block block = this.getBlock(blockpos);
+ IBlockState state = block.getStateFromMeta(this.getBlockMetadata(blockpos));
- if (this.getTileEntity(blockpos, Chunk.EnumCreateEntityType.CHECK) == null && this.getBlock(blockpos).hasTileEntity())
+ if (this.getTileEntity(blockpos, Chunk.EnumCreateEntityType.CHECK) == null && block.hasTileEntity(state))
{
TileEntity tileentity = this.createNewTileEntity(blockpos);
this.worldObj.setTileEntity(blockpos, tileentity);
++++ END PATCH
++++ REJECTED PATCH 17
@SideOnly(Side.CLIENT)
public void fillChunk(byte[] p_177439_1_, int p_177439_2_, boolean p_177439_3_)
{
+ for(TileEntity tileEntity : chunkTileEntityMap.values())
+ {
+ tileEntity.updateContainingBlockInfo();
+ tileEntity.getBlockMetadata();
+ tileEntity.getBlockType();
+ }
+
int i = 0;
boolean flag = !this.worldObj.provider.getHasNoSky();
++++ END PATCH