public boolean setBlockState(BlockPos pos, IBlockState newState, int flags)
{
if (!this.isValid(pos))
{
return false;
}
else if (!this.isRemote && this.worldInfo.getTerrainType() == WorldType.DEBUG_WORLD)
{
return false;
}
else
{
Chunk chunk = this.getChunkFromBlockCoords(pos);
Block block = newState.getBlock();
net.minecraftforge.common.util.BlockSnapshot blockSnapshot = null;
if (this.captureBlockSnapshots && !this.isRemote)
{
blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(this, pos, flags);
this.capturedBlockSnapshots.add(blockSnapshot);
}
int oldLight = getBlockState(pos).getBlock().getLightValue(this, pos);
IBlockState iblockstate1 = chunk.setBlockState(pos, newState);
if (iblockstate1 == null)
{
if (blockSnapshot != null) this.capturedBlockSnapshots.remove(blockSnapshot);
return false;
}
else
{
Block block1 = iblockstate1.getBlock();
if (block.getLightOpacity() != block1.getLightOpacity() || block.getLightValue(this, pos) != oldLight)
{
this.theProfiler.startSection("checkLight");
this.checkLight(pos);
this.theProfiler.endSection();
}
if (blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates
{
this.markAndNotifyBlock(pos, chunk, iblockstate1, newState, flags); // Modularize client and physic updates
}
return true;
}
}
}